Re: [Libclc-developers] new function: clc_strrev
Status: Planning
Brought to you by:
augestad
|
From: <bo...@me...> - 2003-03-23 17:56:32
|
Hallvard B Furuseth wrote:
> Bjørn Augestad writes:
>>Speaking of optimizations, any opinions on code like this?
>>
>>int clc_ultostr(char *ptr, size_t size, unsigned long num, int base)
>>{
>> const char *sym = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
>> char* sp;
>>
>>#ifdef CLC_FAST
>> if(base == 2) { (...) return num == 0; }
>>#endif
>> .... /* regular version goes here */
>>}
>
>
> Since the _whole_ base2 function is special-cased, I think it's better
> to provide a separate base2 function. Then the library still gets
> bigger like you say, but not the application using it.
>
Hmm. A separate base2 function means that the user must call different
functions depending on the speed/size tradeoff he's willing to make. We
discussed the concept of CLC_FAST early in the project, where the
intention of CLC_FAST was to allow for speedier implementations if the
user/builder of libclc wanted that.
I used base2 as an easy-to-implement example, pretty sure that if the
idea catches on, others can provide optimizations for e.g. base 16. We
don't want to call base2, base16, base10 or clc_ultostr() depending on
base, do we?
What if we add clc_ltostr(), clc_lltostr(), clc_itostr() and
clc_ulltostr() for other integer types? Do we want separate base2
functions for them as well?
--
boa
libclc home: http://libclc.sourceforge.net
|