Skip to content

Faster regexes - #3077

Closed
Palloxin wants to merge 56 commits into
Acode-Foundation:mainfrom
Palloxin:patch-1
Closed

Palloxin wants to merge 56 commits into
Acode-Foundation:mainfrom
Palloxin:patch-1

Conversation

@Palloxin

Copy link
Copy Markdown
Contributor

Faster regex improvements

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with a small, non-blocking search-preview issue.

Findings

  1. P2 Search previews lose text boundaries ▶

Summary

This PR replaces many regex operations with string operations and simplifies several remaining patterns.

  • File and text helpers use simpler matching to normalize paths and line endings.
  • Editor themes, modes, and command labels use simpler string matching.
  • File details derive line and word counts with simpler text splits.
  • Display and font helpers use simpler patterns to find and transform text.
  • Build and plugin scripts use simplified matching for project and package text.
  • A comment adds a note about a text-matching expression.

Reviews (16) · Last reviewed commit: "fixed mist" · Reviewed by Greptile

Comment thread src/lib/showFileInfo.js Resolved
Comment thread src/utils/Path.js Resolved
@Palloxin
Palloxin marked this pull request as ready for review November 14, 2026 15:41
@Palloxin

This comment was marked as outdated.

Comment thread src/utils/Path.js Resolved
@UnschooledGamer

Copy link
Copy Markdown
Collaborator

I dont know what that test error is, if someone could help

Ignore that (specific) one. It's Unrelated to your PR!

@AuDevTist1C

AuDevTist1C commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

@AuDevTist1C

AuDevTist1C commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

#3077 (comment)

The test failure appears to be related to https://github.com/Acode-Foundation/canvas-view.

Screenshots

Screenshot_20261115-162858_Chrome Beta.png

git clone https://github.com/Acode-Foundation/canvas-view.git
Screenshot_20261115-163107_Acode.png

@Palloxin
Palloxin marked this pull request as draft November 15, 2026 16:09
@Palloxin
Palloxin marked this pull request as ready for review November 16, 2026 05:07
Comment thread hooks/immersive-fullscreen.js Resolved
Comment thread src/sidebarApps/searchInFiles/worker.js Resolved
@Palloxin

Copy link
Copy Markdown
Contributor Author

Added a triple consecutive replaceAll, this is the reason:
kdjddj

@Palloxin

Palloxin commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Regarding the linting error, I made all commits from mobile with github web page editor. If a dev could fix it in my stead, idk what npm even is :)

Comment thread src/sidebarApps/searchInFiles/worker.js Resolved
@bajrangCoder

bajrangCoder commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Microbenchmarks like jsbench/measurethat time a function in a tight loop; that doesn't show any effect in Acode. These strings are tiny and the code runs a handful of times per action, so a faster replaceAll saves nanoseconds.

Most of this PR changes build steps: Cordova hooks, plugin install scripts and build utilities, plus a vendored library. Those run during builds and gain nothing at runtime, and a wrong regex there can break the build.

A few changes also produce different output, which can break things:

  • console.js: function f(a){...} becomes function f(a)...
  • search previews: a\n\n\nb shows three ⏎ markers instead of one
  • FILE_NAME_REGEX: file names containing a newline are now accepted
  • word count is off by one, and Path.extname("..foo") returns "" instead of .foo

Lint also fails.(This is not a big deal tho)

Performance PRs need a profile from Acode showing the code is an actual bottleneck, with before/after numbers from the app. See Performance Changes in CONTRIBUTING.md. Closing this.

@github-project-automation github-project-automation Bot moved this from Backlog to Done in The Code Board - Acode Nov 16, 2026
@Palloxin

Palloxin commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

I am not capable of producing such data. However for those who know regex and that replaceAll dynamic can know without doubt its objevtive per improvement.

Little things accumulate, a better practice to always give fast code is good.

Lint failed, yes, it is the single quotrs I used, I was fixing it

@Palloxin

Palloxin commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Since I dont know what regex does what, I fished for every regex in the code and every replace => replaceAll dynamic in there, improving them objectively. Objevtively it is an inprovement.

Edit: nvm this pr is a mess, I make it again

@AuDevTist1C

AuDevTist1C commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

#3101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants