Repository navigation
Clean up the engine code - #851
Merged
Merged
Conversation
…nd never crash on it
…thout a conflict
…n the code that will be merged
…ions by what they do
mathiasrw
added this pull request to stack #853
October 23, 2026 16:51
mathiasrw
marked this pull request as draft
October 23, 2026 17:13
… two-line errors of #840
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A code cleanup with no change in what RexReplace does. It is made on main after the whole train was merged.
yarn test-cipasses with the same 1127 tests, and the speed is the same (20 000 matches: 221 ms on main, 229 ms here).Smaller
dynamicReplacement()is 150 lines, not 320. The 48 values were written out twice, and copied once more in the per-match branch. Now one object of names, and the numbers of Only make the --js numbers the code uses, and only count files for $i and $c to close #814 #830, feed one function, which is made once instead of once per file.getFlags()is merged intogetFinalRegex(). TheRE2case was a copy of the runtime case.engine.ts, the colour stubfont,note(), and thedisplayHelpargument ofpanic()withconfig.showHelp.shim.tsis gone.ontoRun.has(target)was the same asinRun.has(target), and it was the only use ofSet.intersection.thrownText()usestryOr()in place of three copies of atry.renamed()is the one place that marks a rename in the status and names it.splitMatch()is the one place that takes the offset, the text and the named groups off the arguments of a replace function.Made once
codeUses()finds once per run what the code of--jsnames, with a plain text search: the named groups, and whether it runs per match, counts what came before, or needs the size or the times. Before, three regexes asked this, and the pattern was compiled again for each file.renameFiles(), the stack trace helpers andthrownText()are inre.One job each
checkFlags()unpackConfig()processFiles()run()readReplacement()matchPrinter()--output-matchplanRenames()checkNameInvalid()checkNameClash()findClashes())src/output.tsnow only prints.src/status.tsis new: it records what happens in a run (warn,error,panic,verbose,checkExpectations,Panic) and prints throughoutput.ts. The detail of an error on its own line (#852) is made there now.config.stoppedis nowconfig.plzStop, as it asks the workers to stop.Names
isFile()ispathKind()and gives'file','glob'ornull.updated()ismarkFileChanged(),info()isprintName(),chat()isverbose(),getFinalPattern()isregexPattern(),handlePipedData()isusePipeAsContent(). The parameters ofdoReplacement()lose the_rrat the end, as the code of the user can not see them anyway.devguide.mdhas the new names.Good to know
/in a new name with--renameis now one of the invalid names, so the messages come in the order of the files, and such a name is no longer also checked for a clash.