[PATCH] Speed up gets

Corinna Vinschen vinschen@redhat.com
Tue Nov 25 17:55:00 GMT 2008


On Nov 24 14:11, Jeff Johnston wrote:
> Corinna Vinschen wrote:
>> Hi,
>>
>> I'd like to propose the below patch.  The current code implements
>> gets/_gets_r in terms of _getchar_r calls.  That means, for every single
>> character of input the following sequence of functions is called:
>>
>>   for each char
>>     _getchar_r
>>       _getc_r
>>         _flockfile
>> 	_sgetc_r
>> 	_funlockfile
>>
>> It should be much quicker to move the locking up into gets itself and to
>> call __sgetc_r right there, as FreeBSD does as well:
>>
>>   _flockfile
>>   for each char
>>     _sgetc_r
>>   _funlockfile
>>
>> That doesn't change the fact that gets is inherently unsecure, of
>> course :)
>>
>> Ok to apply?
>>
>>   
> Yes, please go ahead.

Applied.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat



More information about the Newlib mailing list