Skip to content

util/ocilayout: replace regex for matching windows drive-letters#3825

Merged
crazy-max merged 1 commit intodocker:masterfrom
thaJeztah:noregexp
May 4, 2026
Merged

util/ocilayout: replace regex for matching windows drive-letters#3825
crazy-max merged 1 commit intodocker:masterfrom
thaJeztah:noregexp

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

follow-up to bf34a4c, which changed the isWindowsDrivePath function to use a regex for matching the trailing slash.

This reverts it back to te previous implementation to avoid a regex, but adds a check for the colon to be followed by a forward-slash, which is faster, and avoids the overhead of regex.MustCompile during init.

BenchmarkRegex-11    39056917      32.45 ns/op     0 B/op    0 allocs/op
BenchmarkManual-11   1000000000     0.2476 ns/op   0 B/op    0 allocs/op

follow-up to bf34a4c, which changed the
isWindowsDrivePath function to use a regex for matching the trailing slash.

This reverts it back to te previous implementation to avoid a regex, but
adds a check for the colon to be followed by a forward-slash, which is
faster, and avoids the overhead of `regex.MustCompile` during init.

    BenchmarkRegex-11    39056917      32.45 ns/op     0 B/op    0 allocs/op
    BenchmarkManual-11   1000000000     0.2476 ns/op   0 B/op    0 allocs/op

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@crazy-max crazy-max added this to the v0.34.0 milestone May 4, 2026
@crazy-max crazy-max merged commit 909fc0d into docker:master May 4, 2026
226 of 227 checks passed
@thaJeztah thaJeztah deleted the noregexp branch May 4, 2026 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants