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

Adjust gas for natives #1071

Merged
merged 3 commits into from
Nov 4, 2022
Merged

Adjust gas for natives #1071

merged 3 commits into from
Nov 4, 2022

Conversation

jmcardon
Copy link
Member

@jmcardon jmcardon commented Nov 1, 2022

No description provided.

src/Pact/Gas/Table.hs Show resolved Hide resolved
src/Pact/Gas/Table.hs Show resolved Hide resolved
strToList g i [TLitString s] = computeGas' g i (GMakeList $ fromIntegral $ T.length s) $
return $ toTListV tTyString def $ stringToCharList s
strToList g i [TLitString s] = do
let !len = fromIntegral $ T.length s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here the bang does mean something else: Always compute the length, even if ga is never demanded. I don't think this is necessary, and would rather just let laziness call T.length when and if it needs to, since only one of the arguments to ifExecutionFlagSet' will ever be evaluated, so the bang pattern isn't saving time, it's just shifting the cost of the length from "maybe happens" to "always happens here".

Copy link
Member

@emilypi emilypi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved pending @jwiegley

@jmcardon jmcardon merged commit 0c4aa28 into master Nov 4, 2022
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.

4 participants