Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The level of bikeshedded micro-optimization going on in that file is hilarious. The whole thing could be swapped out with a Ragel parser and nobody would notice a thing


The code is totally wrong, but it least it generates the wrong answer very quickly....


> To make a long story short: very old versions of http_parser were based on a Ragel grammar but the handwritten version outperformed it by a significant margin, as in over 10% fewer branches taken.

> Ragel is great but it can't take shortcuts like a human programmer can and once you start jumping around in your grammar, things become complicated fast (and impossible to debug.)

https://github.com/joyent/http-parser/pull/156#issuecomment-...


So yeah, at least they get the wrong answer quickly.


There is no sense waiting for strncmp. The only logical solution is to replace it with 8 macros.

Anyone looking to purchase a souped up Honda Civic?


This is not optimization or bikeshedding. Optimization is not supposed to break things, it's supposed to make things more efficient. I don't see any examples of bikeshedding either (this is just code; where's the dispute?). This is a broken implementation of a protocol.


> The whole thing could be swapped out with a Ragel parser and nobody would notice a thing

People might notice that it now works correctly. And it might even be faster.


Huh? Nobody has noticed anything even without replacing it. So, the existing code is just fine.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: