[Mesa-dev] [PATCH] glcpp: Rewrite line-continuation support to act globally.

Kenneth Graunke kenneth at whitecape.org
Sat Dec 1 04:13:07 PST 2012


On 11/30/2012 03:20 PM, Carl Worth wrote:
> Kenneth Graunke <kenneth at whitecape.org> writes:
>> Other than than, looks good to me...thanks Carl!
>>
>> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
>
> Thanks, Ken. Pushed now.
>
>> Someday we may want to use ralloc's rewrite_tail functions to avoid the
>> extra strlen() overhead.  But that can be done separately.
>
> I took a look at this now. It looks like there are only rewrite_tail
> variants of ralloc_asprintf, which feel heavy here. I'd prefer a variant
> of ralloc_strcat that would give the better efficiency, (and the
> documentation of ralloc_strcat could then point to the alternate
> function).
>
> Perhaps the new function could be named ralloc_rewrite_tail? Compared to
> something like ralloc_strcat_rewrite_tail that would be a less awkward
> name, and would also avoid suggesting that the new string is always
> appended to the end, (in the case where the passed length is shorter
> than the current string's length).

Yeah, I'm definitely in favor of creating a ralloc_rewrite_tail function.

I almost added them when I reworked the preprocessor, but a bunch of the 
calls needed printf-like functionality anyway, so I decided just to use 
it everywhere and put off making a new function.

> The only naming question left after that would be what to name the
> tail-rewriting variant of ralloc_strncat?
>
> -Carl

Sadly, that is the trickiest part :)  I do like "ralloc_rewrite_tail", 
as it's simple and feels natural.  It doesn't mention strings, but I 
don't think it needs to.

Going with that, perhaps ralloc_rewrite_tail_n()?

Another alternative would be ralloc_strn_rewrite_tail(). That seems 
fairly clear (the "strn" concept is familiar, and can be pronounced 
"stern"...), but it almost begs for ralloc_str_rewrite_tail() for 
consistency.  And that doesn't roll off the tongue as well.

I'm pretty tempted by ralloc_rewrite_tail & ralloc_strn_rewrite_tail.


More information about the mesa-dev mailing list