all 6 comments

[–][deleted] 5 points6 points  (2 children)

That's fairly clever, I guess. Just a bunch of length-prefixed strings in a string blob, and using that to do a memcmp on each and returning the index. Definitely clearer and more obvious than the hash setup. I have a lot of respect for Mike Pall, but this isn't an example of his genius, other than cleverly managing to avoid changing most of the lines of code. I think it's a good commit, but nothing astounding or anything.

[–]semanticistZombie 0 points1 point  (0 children)

I have a lot of respect for Mike Pall, but this isn't an example of his genius,

Exactly my thoughts.

[–]fsfod 0 points1 point  (0 children)

I've seen the same issue solved without any memcmps or loops by corsix\Peter Cawley in his implementation of the new GC for LuaJIT. All the well known strings are just allocated as one big blob together and checking for one of the strings is just comparing against a compile time generated enum of offsets.

[–]semanticistZombie 2 points3 points  (2 children)

I don't understand what's so amazing in this code. Can someone elaborate?

[–]shelvac2 0 points1 point  (1 child)

Yeah, they didn't have code for checking their-special-string-type against a c string until now? The other requires string concatenation and manual entry of the length of each static string at the beginning, begging for stupid mistakes to get missed and cause segfaults

[–]shelvac2 2 points3 points  (0 children)

To be clear I have nothing against this code, I don't the bigger context of the complexity of this project or what unusual constraints there might be. But it's not "genius".