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

Copy link
Copy Markdown
Contributor

When evaluating pull requests and performance benchmarks, it is essential to account for the stark hardware realities and environmental constraints faced by developers around the world.

Some devs like me do not own a personal computer, and our working family members are unable to purchase one due to financial limitations, forcing us to write and test code entirely on budget mobile devices.

Major browser vendors consistently refuse to implement native mobile DevTools support without desktop PC reliance, dismissing mobile debugging capabilities under the umbrella of performance concerns.

While there is currently only one mobile browser capable of handling such tasks—namely, Kiwi Browser—it remains stuck on an ancient version of Chromium because its solo developer has long abandoned active maintenance due to personal time constraints.

Given these systemic hardware barriers that prevent mobile-only contributors from capturing traditional desktop profiling metrics, is there any other way to get "a profile from Acode showing the code is an actual bottleneck, with before/after numbers from the app"?

Exploring alternative lightweight logging or in-app measurement techniques would greatly assist developers with limited resources in meeting contribution standards without requiring expensive desktop hardware.

Google Gemini 3.5 Flash-Lite "with auto selection"

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