Re: [PATCH 11/13] strbuf: add strbuf_add*_urlencode
- From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
- Date
- Nov 30, 2011, 05:41 UTC
- Message-ID
- <4ED5C211.6040401@lsrfire.ath.cx>
- In-Reply-To
- <20111130032028.GA24704@sigill.intra.peff.net>
Am 30.11.2011 04:20, schrieb Jeff King:
Show 22 quoted lines
> On Wed, Nov 30, 2011 at 12:26:20AM +0100, René Scharfe wrote:
>
>>>>> +static int is_rfc3986_reserved(char ch)
>>>>> +{
>>>>> + switch (ch) {
>>>>> + case '!': case '*': case '\'': case '(': case ')': case ';':
>>>>> + case ':': case '@': case '&': case '=': case '+': case '$':
>>>>> + case ',': case '/': case '?': case '#': case '[': case ']':
>>>>> + return 1;
>>>>> + }
>> [...]
>> Sorry for my bikeshedding, but I'd paint it like this:
>>
>> return !!strchr("!*'();:@&=+$,/?#[]", ch);
>
> I was always under the impression that computed jumps via "switch" would
> out-perform even an optimized strchr. Of course, I never tested. And I
> doubt performance is even relevant here, and I admit I don't care overly
> much. I find them both equally readable.
>
> I'm going to leave it as-is unless somebody else wants to say "I
> strongly prefer version X".Sure, the second one is significantly slower than the first one. I just prefer it based one its looks in case performance doesn't matter, but that's probably just me being (sometimes too) fond of terseness. :)
René