5 ms·
Yes, I was shocked to learn this about early PHP, that function names were hashed simply by their lengths - so names were chosen to fit a specific length. Pragm
by lioeters 7y ago
Yes, I was shocked to learn this about early PHP, that function names were hashed simply by their lengths - so names were chosen to fit a specific length. Pragmatic and fast? Yes. Insane design? Completely.
Edit: I can also imagine this design decision must have had context. Perhaps it was a common technique in low-level programming, as a practical way to save time/space.
- johannes1234321 7y agoGiven the amount of functions in early PHP (we are talking PHP/FI 2 max here, even userlevel code hardly had functions back then) even not hashing them at all, but doing a linear search over the function table would have been acceptable. Hashing by length most likely lead to few buckets with more than 3 functions.