Command processing
Trond Norbye
Trond.Norbye at Sun.COM
Mon Mar 10 18:28:54 UTC 2008
On Mar 10, 2008, at 5:35 PM, Roy Lyseng wrote:
>
> marc at corky.net wrote:
>> Roy Lyseng wrote:
>> In reality, a full blown string compare is not even needed in this
>> case. One can loop through the command array comparing the first
>> character only, then the second, etc. If the actual length of the
>> command is stored in the array as well and the length of the
>> requested command is done beforehand, one needs to at most only
>> compare two characters and the length. From a quick look only the
>> get/gets commands both start with the same two characters -
>> therefore the length must also be compared. Otherwise the entire
>> string in this particular case.
>
> Yes - and I guess strcmp() will bail out after the first non-match.
I don't _think_ that we will see much difference in the speed, but I
think that it will make the source more readable :-)
Trond
More information about the memcached
mailing list