Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: allow matching against byte[] instead of String #14

Open
hyperpape opened this issue Mar 19, 2024 · 0 comments
Open

Idea: allow matching against byte[] instead of String #14

hyperpape opened this issue Mar 19, 2024 · 0 comments

Comments

@hyperpape
Copy link
Owner

hyperpape commented Mar 19, 2024

Matching against a byte[] is likely to have lower overhead than matching against a String, as the compiled code would no longer contain as much functionality inlined from String#charAt. If that's true, then it might sometimes be good to have a version of the code that operates on byte[] instead of String.

There are two cases you can imagine here:

  1. A caller might already have a byte[], and want to match against it.
  2. It might be true that even if you already have a String, it's faster to convert to a byte[]

I have no intuition whether the second possibility is ever true.

Since the current version of the code only cares whether it's getting data from a String when it calls String#charAt, the internal implementation would probably not be that complicated. We might have to support an alternate version of the Pattern interface that accepts byte[] (I don't think we'd want to include the byte[] based methods on the standard interface?).

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

No branches or pull requests

1 participant