🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.borland
Article #551

Re: Speed of Delete - improvement

#551
From: Dr John Stockton
Date: Tue, 18 Nov 1997 00:00
31 lines
1960 bytes
In article <s2qpaAAJUIc0EwPB@merlyn.demon.co.uk> of Mon, 17 Nov 1997
17:55:21 in comp.lang.pascal.borland, Dr John Stockton
<jrs@merlyn.demon.co.uk> wrote:
>...   I have given a little thought to the Delete routine (for
>string-handling).
> ...

Today's routine is nicer and a bit faster than yesterday's :-

  procedure Remove(var S : string ; Index, Count : Integer) ;
  { JRS's faster replacement for Sys.DELETE }
  var Tmp : integer ;
  begin
    if (Count<=0) or (Index<=0) or (Index>Length(S)) then EXIT ;
    Tmp := Length(S)-Index+1 { Maximum Removable } ;
    if Count>=Tmp then Count := Tmp else
      Move(S[Index+Count], S[Index], Tmp-Count) ;
    Dec(S[0], Count) end {Remove} ;

>The current test program should be in 
>        http://www.merlyn.demon.co.uk/programs/del_timr.pas
>by the time you read this - and may change at any time.

Changed; new code, more tests.
 
-- 
John Stockton, Surrey, UK.    jrs@merlyn.demon.co.uk    Turnpike v1.12    MIME.
  Web URL: http://www.merlyn.demon.co.uk/ - FAQqish topics, acronyms and links.
  Correct 4-line sig separator is as above, a line comprising "-- " (SoRFC1036)
  Before a reply, quote with ">" / "> ", known to good news readers (SoRFC1036)
Technical Details
Message-ID: <DBS2jCAmrdc0Ew4E@merlyn.demon.co.uk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <s2qpaAAJUIc0EwPB@merlyn.demon.co.uk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10261c,9e270db731f7d69c
X-Google-Attributes: gid10261c,public
X-Google-Thread: 108ebd,9e270db731f7d69c
X-Google-Attributes: gid108ebd,public
X-Google-Thread: 111659,9e270db731f7d69c
X-Google-Attributes: gid111659,public
From: Dr John Stockton <jrs@merlyn.demon.co.uk>
Subject: Re: Speed of Delete - improvement
Date: 1997/11/18
Message-ID: <DBS2jCAmrdc0Ew4E@merlyn.demon.co.uk>
X-Deja-AN: 290504918
Distribution: world
X-NNTP-Posting-Host: merlyn.demon.co.uk [158.152.233.145]
References: <s2qpaAAJUIc0EwPB@merlyn.demon.co.uk>
Organization: Home, Surrey, UK
Newsgroups: comp.lang.pascal.borland,comp.lang.pascal.misc,borland.public.turbopascal