Skip to content

[opt] Don't recompute initial literals price#2028

Merged
terrelln merged 3 commits intofacebook:devfrom
terrelln:minor-opt
Mar 5, 2020
Merged

[opt] Don't recompute initial literals price#2028
terrelln merged 3 commits intofacebook:devfrom
terrelln:minor-opt

Conversation

@terrelln
Copy link
Contributor

@terrelln terrelln commented Mar 5, 2020

The pricing of opt[0].price doesn't matter at all for the parsing, since every path contains opt[0]. I've left the litlen price in so we don't get negative prices when we subtract it off.

I don't expect more than any real gains, except maybe on a specifically constructed dataset, but no need to do the extra work.

@Cyan4973
Copy link
Contributor

Cyan4973 commented Mar 5, 2020

OK, so the main idea seems to be that
the algorithm doesn't need the full price of all literals in front of the first match,
but only the cost of the literal length,
since the cost of literals themselves forms a kind of "static" sum which will not vary whatever the decision after that point ?

@terrelln
Copy link
Contributor Author

terrelln commented Mar 5, 2020

Yup, I've added a comment saying that. We don't "need" the cost of the literal length either, but I don't want the price to be negative when we subtract it off later.

@terrelln terrelln merged commit 04744e5 into facebook:dev Mar 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants