Skip to content
This repository has been archived by the owner on Jul 26, 2018. It is now read-only.

Capture buffer enhancements #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wqweto
Copy link

@wqweto wqweto commented Feb 5, 2017

This PR allows setting capture text buffer (G->text member) initial size separately from G->buf initial size. The new optional constant is YY_TEXT_START_SIZE with a default of 1024 to preserve current behavior.

Setting YY_TEXT_START_SIZE to 0 takes care for the generated parser to not copy capture's text to G->text inside internal yyText function. This allows for copyless strategies in actions using direct access to G->buf with yycapture.begin/yycapture.end which minimized string coping/allocation.

With this change alone speed-up might be significant as greg produced parsers contain a lot of "just-in-case" calls to yyText (e.g. before expanding YY_BEGIN and YY_END macros) and usually capture strings get copied once again in actions before getting passed on the receiving callback interface (e.g. using strdup) anyway.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant