Content pfp
Content
@
0 reply
0 recast
2 reactions

Krishang pfp
Krishang
@krishang
evm nerds, what's an efficient Huff lang implementation of this 'SimpleStringStore' ? i can write a bad and costly one. please teach me, thanks
1 reply
0 recast
1 reaction

horsefacts pfp
horsefacts
@horsefacts.eth
Have you read this brief section in the Huff docs on "Hello World?" https://docs.huff.sh/tutorial/hello-world/#primer-abi-encoding I'd start with the way Solidity does it, then try to do better: https://docs.soliditylang.org/en/latest/internals/layout_in_storage.html#bytes-and-string
1 reply
0 recast
2 reactions

horsefacts pfp
horsefacts
@horsefacts.eth
That is: - If the string is long, store the length in slot n and each word of the data in slot keccak(n) + i - If the string is short, pack the length and data in a single slot.
1 reply
0 recast
0 reaction

horsefacts pfp
horsefacts
@horsefacts.eth
...then you can start making more simplifying assumptions. For example, since this stores a single string and has no other state variables, you could skip the keccak, and just store length + data sequentially starting from slot 0.
0 reply
0 recast
0 reaction

Krishang pfp
Krishang
@krishang
I solved 'huff-puzzles' and played around with strings in general: https://github.com/nkrishang/huff-puzzles-solutions My `SimpleStringStore` includes multiple storage read / writes and I have a hunch that I'm missing fundamental understanding that leads to those multiple storage read/writes
1 reply
0 recast
0 reaction

Krishang pfp
Krishang
@krishang
I'll post my `SimpleStringStore` solution in a bit !!
0 reply
0 recast
1 reaction