Skip to content

Post-#504 minor cleanups and observations #511

Description

@bertysentry

Final-review observations from #504 that were deliberately left out of the PR — each is minor, and some are trade-off decisions rather than defects.

1. JRT.isJrtManagedSpecialVariable style consistency

isJrtManagedSpecialVariable is an ||-chain of equals while its sibling applySpecialVariable is a switch; both its call sites are cold, so this is consistency-only.

2. Dynamic (string) regexps are compiled on every call

JRT.matches, matchPosition, and replaceFirst/replaceAll compile dynamic string patterns with Pattern.compile(ere, regexpFlags()) on each invocation. This is pre-existing behavior that #504 merely relocated into the JRT; the IGNORECASE pattern-twin cache intentionally covers only precompiled regexp constants. If profiling ever shows a hot gsub(dynstr, ...) loop, a small string-keyed pattern cache would slot naturally next to JRT.caseAwarePattern.

3. gensub occurrence loop uses StringBuffer

Required while the project targets Java 8: Matcher.appendReplacement(StringBuilder, String) only exists since Java 9. Worth switching if/when maven.compiler.release moves past 8.

4. Redundant subarray re-check in the sort tie-break

GawkExtension.compareNumericThenText excludes Map operands, then its string tie-break calls compareStrings, which re-checks the same two instanceofs on a path where they can no longer be true. Harmless dead check; folding it away would tangle the comparator helpers, so it was left as-is.

Spun out of the final review of #504.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions