2 ms·
Pulling this up out of a subthread, if you happen to have some sort of notification set up for these: https://gist.github.com/saagarjha/00faa1963023206a8ccd9877
by saagarjha 6y ago
Pulling this up out of a subthread, if you happen to have some sort of notification set up for these: https://gist.github.com/saagarjha/00faa1963023206a8ccd9877983b4546 https://gist.github.com/saagarjha/00faa1963023206a8ccd987798.... Not intended to be robust or even correct beyond "I tried it a little and it seems to work".
- tptacek 6y agoTIL <ftw.h>! You can golf out about 10 lines of this by getting rid of the table free. :)
- saagarjha 6y agoYes, ftw.h has a couple of nice functions–it's an apt name in this case ;) I could have done a number of things to keep the line count down–in the spirit of the challenge I tried to keep it clean, pedantic, idiomatic POSIX C because if I didn't I'm sure someone would have jumped on it for it not being that :P So it's written in nano in the style of how I might write a homework assignment rather than something I specifically golfed. In retrospect the fixed-depth buckets probably added more complexity than they saved, and using a linked list or open addressing would have probably been much easier since it'd clean up some of the resizing and traversal code. Plus, the load factor was in general fairly poor, the final table (when I ran it on my Downlods folder) had just over 8 million buckets of depth 5 allocated and only about 600k got used at all, and of that 570k were filled just once. Oh, and here's the results on my Downloads folder: 514464 Developer 425236 Xcode 386616 saagarjha 386075 Users 361324 Library 337374 build 333056 Wno 306758 WebKit 302892 DerivedData 296179 eugbibmfmfphgbhczsxiimkhynol I have a couple WebKit build logs that dominated the results…