Re: Function speed, which is fast

From: Frank de Groot (franciad_at_online.no)
Date: 11/12/04


Date: Fri, 12 Nov 2004 17:35:14 +0100


"L D Blake" <not@any.adr> wrote in message
news:ipi8p0hdfdkmjqu842q13gbo4si5pf4bha@4ax.com...

> Which is going to take longer...
>
> Allocate string,
> Add 1 character,
> Reallocate string,
> done: copy to new string
> or
>
> write 1 character to static memory
> increment pointer
> cast as string (no conversion, it reads it in place)
>
> Really... string buffers are just so cool.

You haven't understood my example.

Your method is slower, less easy to read, more effort to type, and more
non-standard than my method.

I allocate length once for the entire string, then add the characters, then
set the length to the correct size.



Relevant Pages

  • [TOMOYO #15 3/8] Common functions for TOMOYO Linux.
    ... This file contains common functions (e.g. policy I/O, pattern matching). ... Since TOMOYO Linux is a name based access control, ... TOMOYO Linux's string manipulation functions make reviewers feel crazy, ... the Linux kernel accepts all characters but NUL character ...
    (Linux-Kernel)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • RfD: Escaped Strings version 4
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... as an escape character for the entry of characters that cannot be ... \b BS (backspace, ASCII 8) ...
    (comp.lang.forth)
  • Re: RfD: Escaped Strings
    ... the S" string can only contain printable characters, ... the S" string cannot contain the '"' character, ... \b BS (backspace, ASCII 8) ... \ ** escapes to characters much as C does. ...
    (comp.lang.forth)
  • Re: A note on computing thugs and coding bums
    ... code is valid for any character set that is legal in C (which is a ... characters in the required source character set ... A String, in C Sharp or Java, can be redefined. ... allow programmers to handle some other data format, ...
    (comp.programming)