daokoder / dao-modules

Dao Standard Modules
http://daovm.net
12 stars 5 forks source link

Minor: Use gperf for http date headers parsing #60

Closed dumblob closed 9 years ago

dumblob commented 9 years ago

Because header parsing will be executed very often, the O(n^2) complexity (for all days/months call strncmp() consequently) should be reduced to O(n) (and strncmp() avoided) e.g. by using gperf-generated perfect hash matching (btw it's already used for Dao language parsing).

Night-walker commented 9 years ago

The current parsing is meant to be efficient, but without sacrificing simplicity. Dates, for instance, are not interpreted during header parsing. For now at least, squirting out a small performance boost is much less important then keeping things simple and maintainable.

If the parsing ever become a bottleneck, then it can be improved. But I don't want to spend time on preemptive optimizations. Of course, you can always do it yourself and post the patch here :)

dumblob commented 9 years ago

Yes, lots of minor improvements can be done, but this one kinda punched me in my face as I somehow felt it more significant than all the other ones :wink:

Of course, you can always do it yourself and post the patch here :)

Sure. That reminds me of my question https://github.com/daokoder/dao-modules/issues/39#issuecomment-89608668 about pull requests.

Night-walker commented 9 years ago

Sure. That reminds me of my question #39 (comment) about pull requests.

Which reminds me of another question #39 about using Git.

Night-walker commented 9 years ago

Closing because it's not significant and I don't intend to do it.