Re: TeamB, Borland, admit obvious

From: Barry Kelly (barry_j_kelly_at_hotmail.com)
Date: 03/09/04


Date: Tue, 09 Mar 2004 20:55:58 +0000

On Fri, 5 Mar 2004 13:10:56 +0100, "Hrvoje Brozovic" <a.b@c.de> wrote:

> Using the plus (+) operator has the same effect on two
> strings as using the Concat function:
> S := 'ABC' + 'DEF';
>
> Tip: The plus operator is faster than Concat.
>
> MY NOTE: Borland encourages developers to use it.

> s1 := s2 + s3 calls LStrCat3
> s1 := s1 + s2 calls LStrCat
>
> MY NOTE: Obviously s1 += s2 is treated as special case by Borland.

However, LStrCat cannot know how long the final string is going to be.

> MY NOTE: Borland always tries to resize in place,

Again, this *might* work *once*.

> When performing repeated concatenations of the type:
> For I = 1 To N
> Dest = Dest & Source
> Next N
>
> the length of time increases proportionally to N-squared.

This is true in Delphi and VB and in any other language compiler which
cannot fortell the future. I recommend using a TStringList or
something similar to build very long chains of concatenations.

> Steps 2 and 6 are very expensive and basically ...

A constant time increase, irrelevant as it will be dominated by the
n^2 function observed earlier.

> MY NOTE: to achieve performance in the same order of magnitude (but still
> much slower) as Delphi,
> Microsoft has nothing to offer Visual Basic developers other than hack.

This is incorrect. The Delphi native code is only slightly better than
VB, and only by a constant factor.

> If you going to use StringBuilder, it cant pass as
> minor change in anybody's book.

I already used TStringList as a StringBuilder, so I personally don't
see the problem.

-- 
Barry Kelly
If you think the problem is bad now, just wait until we've solved it.
  -- Arthur Kasspe


Relevant Pages

  • Re: 3vl 2vl and NULL
    ... >> Frank Hamersley wrote: ... >> the same entities and attributes to model, your UML diagrams would be ... >> We take data in from a screen as strings, ... >> the interface between dbms and humans (developers)? ...
    (comp.databases.theory)
  • Re: 3vl 2vl and NULL
    ... >> Frank Hamersley wrote: ... perhaps (somewhat similar to XML developers thinking in ... >> strings), but my reason in this case is that although you might cast to ... > Thirdly I have done the measuring over the last 25 years! ...
    (comp.databases.theory)
  • Re: substring finding problem!
    ... overlapping strings. ... dangerous because it finds overlapping strings, ... I do think that for the same reason your notion of "concat" ... strange things can happen outside programming, and programmers, even ...
    (comp.lang.c)
  • Re: GT.M V5.3-004A released
    ... Because Cache defaults to allowing a single global node to contain up ... Given that a lot of new GT.M developers are going to be experienced ... strings will increasingly become the norm in GT.M systems. ...
    (comp.lang.mumps)
  • Re: Optimization question
    ... However, most Oberon implementations would ... I question the use of 'Delphi' and 'elegant' in the same sentence. ... handling of strings is a particularly good example. ... Strings are a bit of a mystery to most Delphi developers. ...
    (comp.lang.oberon)