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

feat(capi+go): expose match data (strings) via YRX_MATCH #249

Closed
wants to merge 1 commit into from

Conversation

egibs
Copy link

@egibs egibs commented Nov 20, 2024

I noticed that the API currently does not expose the strings from a given match while the CLI does:

let match_data = m.data();

Since matches are already plumbed into the Go API, this was a pretty small lift but I still wanted to capture the desired behavior with a couple of test updates.

If there's a better or more appropriate implementation for this, please let me know!

cc: @tstromberg

Copy link

google-cla bot commented Nov 20, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@plusvic
Copy link
Member

plusvic commented Nov 20, 2024

Not including the matched data in the structure was an intentional decision. The matching strings can be many, and very long, and exposing them in Go API requires copying the data via C.GoBytes. Making copies of very long strings is expensive.

Also, these copies are not necessary after all, because the user of the API already knows their lengths and offsets within the original data, and the user of the API must have access to the data in order to pass it to the scanner in the first place.

@plusvic plusvic closed this Nov 20, 2024
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