list(,$nfields) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
The question is, why "N*" if substr should return 4 bytes, and they will be unpacked as N? And why double assignment?
UPD: This code is part of Sphinx native PHP connector. After some code hacking it became clear that this code extracts 4-byte integer. But logic behind double assignment and substr / N* is still unclear to me. I’m offering a bounty to finally understand it.
We’d need to see the revision history of the file but some possibilities are:
These are all synonyms:
I did the typical repeat-a-thousand-times benchmark with three integers and 1 is way faster. However, a similar test with 10,000 integers shows that 1 is the slowest :-!
Being a full-text engine where performance is a must, I’d dare say it’s an optimization.