monochromegane/the_platinum_searcher — pull request #29 by shantanugoel (2014-05-07 16:24:51+00:00)
Title: Make filetype detection faster

Noticed that pt was running slower today on my code while it was pretty fast last night. Then realized that I had compiled the build since then and there were lot of binaries (some of them pretty big running into >200-300 MB) for which I hadn't updated my ignore rules. On further inspection, noticed that pt is loading the full file to do the filetype detection while it checks only first 512 bytes to take a decision.
Changed the code to read only a max of 512 bytes for file type detection and it was almost as fast again :)

Please check the changes.