apache / apache/pekko-management

use compiled regex

Open
#852 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Scala
Stars
33
Forks
19
Avg merge
4h 48m
Merged PRs (30d)
29

Description

I don't think that any of the regex code in this module is on the hotpath but we could potentially change our String.replaceAll(regex, newValue) calls with:
```
import java.util.regex.Pattern

val UNDERSCORE_OR_DOT = Pattern.compile("[_.]")
val Pattern INVALID_CHARS = Pattern.compile("[^-a-z0-9]")

val str: String = ...
val withHyphens = UNDERSCORE_OR_DOT.matcher(lower).replaceAll("-")
val normalized = INVALID_CHARS.matcher(withHyphens).replaceAll("")
```

There are 5 or 6 different regexes that could be looked at.

Contributor guide

Open the contributing guide

Research direction

Start by locating the five or six regex uses in the module, especially the String.replaceAll calls described in the issue. Compare the existing replacements with compiled java.util.regex.Pattern usage, then run the relevant existing tests to confirm behavior is unchanged for underscore, dot, and invalid-character normalization.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
performance
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.