News for hackers. Stuff that matters.
Re:C++ still isn't cutting it by saagarjha on Sunday October 18, 2020 @05:58PM (#24821454)
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/00faa1963023206a8ccd987798.... Not intended to be robust or even correct beyond "I tried it a little and it seems to work".
Re:C++ still isn't cutting it by tptacek on Sunday October 18, 2020 @07:08PM (#24821861)
TIL <ftw.h>!

You can golf out about 10 lines of this by getting rid of the table free. :)

Re:C++ still isn't cutting it by saagarjha on Monday October 19, 2020 @04:15AM (#24824245)
Yes, 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…