Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hammer
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Letitia Li
hammer
Commits
dd5cc15a
Commit
dd5cc15a
authored
9 years ago
by
Meredith L. Patterson
Browse files
Options
Downloads
Patches
Plain Diff
shave off another ~500ns/iter by not initialising HLeftRecs we'll never use
parent
99ca500d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/backends/packrat.c
+3
-2
3 additions, 2 deletions
src/backends/packrat.c
with
3 additions
and
2 deletions
src/backends/packrat.c
+
3
−
2
View file @
dd5cc15a
...
@@ -188,9 +188,10 @@ HParseResult* h_do_parse(const HParser* parser, HParseState *state) {
...
@@ -188,9 +188,10 @@ HParseResult* h_do_parse(const HParser* parser, HParseState *state) {
// check to see if there is already a result for this object...
// check to see if there is already a result for this object...
if
(
!
m
)
{
if
(
!
m
)
{
// It doesn't exist, so create a dummy result to cache
// It doesn't exist, so create a dummy result to cache
HLeftRec
*
base
=
a_new
(
HLeftRec
,
1
)
;
HLeftRec
*
base
=
NULL
;
// But only cache it now if there's some chance it could grow; primitive parsers can't
// But only cache it now if there's some chance it could grow; primitive parsers can't
if
(
parser
->
vtable
->
higher
)
{
if
(
parser
->
vtable
->
higher
)
{
base
=
a_new
(
HLeftRec
,
1
);
base
->
seed
=
NULL
;
base
->
rule
=
parser
;
base
->
head
=
NULL
;
base
->
seed
=
NULL
;
base
->
rule
=
parser
;
base
->
head
=
NULL
;
h_slist_push
(
state
->
lr_stack
,
base
);
h_slist_push
(
state
->
lr_stack
,
base
);
// cache it
// cache it
...
@@ -207,7 +208,7 @@ HParseResult* h_do_parse(const HParser* parser, HParseState *state) {
...
@@ -207,7 +208,7 @@ HParseResult* h_do_parse(const HParser* parser, HParseState *state) {
cached
->
input_stream
=
state
->
input_stream
;
cached
->
input_stream
=
state
->
input_stream
;
}
}
// setupLR, used below, mutates the LR to have a head if appropriate, so we check to see if we have one
// setupLR, used below, mutates the LR to have a head if appropriate, so we check to see if we have one
if
(
NULL
==
base
->
head
)
{
if
(
!
base
||
NULL
==
base
->
head
)
{
h_hashtable_put
(
state
->
cache
,
key
,
cached_result
(
state
,
tmp_res
));
h_hashtable_put
(
state
->
cache
,
key
,
cached_result
(
state
,
tmp_res
));
return
tmp_res
;
return
tmp_res
;
}
else
{
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment