On Saturday 24 October 2009 20:15, Paul Smith wrote:
> On Sat, 2009-10-24 at 17:21 +0200, Denys Vlasenko wrote:
> > There should be a way to shut up gcc in these places only
> > instead of pessimizing the code. At least I hope so.
> 
> I've not done any measurements, but it seems reasonable to me that the
> ("%s", string) form would be at least as efficient, if not moreso.
> 
> Consider: if you pass the string as the first argument then
> bb_error_msg() needs to search the entirety of the string checking each
> character to see if it's special and handling it appropriately.

We don't do millions of bb_error_msg's per second.
The whole argument is about not wanting to use larger
bb_error_msg("%s", str)
when bb_error_msg(str) would work too.

> If you use "%s" as the format, then immediately bb_error_msg() can see
> that it takes the next argument as a whole, without needing to process
> or interpret it in any way: just a strcpy() or whatever.

internal strchr(str, '%') is very cheap compared to write syscall.

--
vda
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to