Hi!

----

[The following falls under the category "micro-optimisation" but may IMO
still be worth an investigation]
After working on various parts of OpenSolaris I found that is common to
use the following sequence to concatenate strings:
-- snip --
...
char *s;
...
strcat(s, "foo");
strcat(s, "/");
strcat(s, "bar");
-- snip --
(note: The example is simplified, normally { "foo", ",", "bar" } are
normal strings and no static string literals)
while this code is simple and easy to understand it is quite inefficient
- |strcat()| will always walk |s| each time. If |s| already contains a
large path this will be horrible time-consuming.

Back in the 1990 timeframe there was the "DICE C" compiler for AmigaOS
(AFAIK SAS C/C++ had something similar - but I am not sure) which solved
this issue quite cleanly via having a special version of |strcat()|
which returned the end of the string instead of the beginning (like
ANSI-C |strcat()| does) ... I don't remember the functions's name in
"DICE C" anymore - lets call it |strFOOcat()| for now...

... the idea would be to introduce the same functionality to Solaris's
libc+kernel to make such cases much faster (and carry the idea to the
standard bodies (ISO-C and whoever maintains the widechar interfaces)
for inclusion).

Proposed functions would be (with "FOO" replaced with a better name):
|strFOOcat()| - like |strcat()| but returns the pointer to '\0'
|wcsFOOcat()| - like |wcscat()| but returns the pointer to '\0'
|wsFOOcat()| - like |wscat()| but returns the pointer to '\0'

Comments/suggestions/ideas welcome...

----

Bye,
Roland

P.S.: Does anyone know how "DICE C" called the function ?

-- 
  __ .  . __
 (o.\ \/ /.o) [EMAIL PROTECTED]
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 7950090
 (;O/ \/ \O;)
_______________________________________________
opensolaris-discuss mailing list
opensolaris-discuss@opensolaris.org

Reply via email to