Newsgroups : Borland : borland.public.delphi.rtl.win32 : 2005 Mar : WideString implementation
| Subject: | WideString implementation |
| Posted by: | "Rob Kennedy" (.) |
| Date: | Thu, 3 Mar 2005 01:24:25 |
Can anyone tell me why the WideString support routines in System.pas
seem so strange? For instance, WStrAsg, which is called when assigning
the result of a function to a WideString variable, is implemented using
SysReallocStringLen. Why not just do a simple assignment, A := B?
SysReallocStringLen is documented to make a copy of the source string
and destroy the original. (In fact it doesn't always do that; it will
re-use the original sometimes.)
WStrSetLength, which seems like the perfect opportunity for wrapping
SysReallocStringLen, doesn't call that API function. Instead, it will
always make a new copy of the string and destroy the original, no matter
how the length of the string is changing -- even if the length isn't
changing at all.
Both RTL functions seem to require unnecessary memory allocation and
de-allocation
--
Rob