newStringOfCap implemented and used to optimize some procs

This commit is contained in:
Araq 2011-05-08 17:38:34 +02:00
commit d2e2d71d05
10 changed files with 53 additions and 21 deletions

View file

@ -685,7 +685,13 @@ proc newString*(len: int): string {.
## content. One needs to fill the string character after character
## with the index operator ``s[i]``. This procedure exists only for
## optimization purposes; the same effect can be achieved with the
## ``&`` operator.
## ``&`` operator or with ``add``.
proc newStringOfCap*(cap: int): string {.
magic: "NewStringOfCap", importc: "rawNewString", noSideEffect.}
## returns a new string of length ``0`` but with capacity `cap`.This
## procedure exists only for optimization purposes; the same effect can
## be achieved with the ``&`` operator or with ``add``.
proc `&` * (x: string, y: char): string {.
magic: "ConStrStr", noSideEffect, merge.}