Skip to content

Comments

regex: Speed-optimized PCRE implementation.#26609

Merged
spytheman merged 8 commits intovlang:masterfrom
penguindark:vpcre
Feb 15, 2026
Merged

regex: Speed-optimized PCRE implementation.#26609
spytheman merged 8 commits intovlang:masterfrom
penguindark:vpcre

Conversation

@penguindark
Copy link
Member

What's inside

  • optimizations for speed
  • less memory used
  • avoided every recursion
  • stack depth selection with function change_stack_depth() for particular case

What's good

  • code with less of 700 rows of code
  • good separation between compiler and executor
  • stack depth configurable

What's not good

  • large use of goto in order to increase the speed

What's next

  • more tests vs C/C++ and Python libs in order to compare the speed achieved.

Optimization

  • Pre-allocated Machine workspace: All search operations are zero-allocation.
  • Raw pointer access: Bypasses bounds checking for string and instruction access.
  • Fast ASCII Path: Characters < 128 bypass heavy UTF-8 decoding.
  • Instruction merging: Consecutive character matches are merged into string blocks.
  • Bitmap lookups: ASCII character classes use a 128-bit bitset for O(1) matching.

AI support: Gemini 3 Pro preview and a lot of my personal effort because AI is too stupid to understand same basic concepts. 😢

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ba95cbb5ae

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Copy link
Contributor

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @penguindark 🙇🏻 .
Excellent work.

@spytheman spytheman merged commit 97f5b89 into vlang:master Feb 15, 2026
78 checks passed
@penguindark penguindark deleted the vpcre branch February 15, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants