Browse Source

* some speed improvements for string operations

pierre 24 years ago
parent
commit
e7cff5c48c
4 changed files with 52 additions and 24 deletions
  1. 5 2
      ide/fpini.pas
  2. 8 3
      ide/fpusrscr.pas
  3. 23 15
      ide/wansi.pas
  4. 16 4
      ide/wutils.pas

+ 5 - 2
ide/fpini.pas

@@ -185,7 +185,7 @@ begin
   C:='';
   C:='';
   for I:=1 to length(S) do
   for I:=1 to length(S) do
     begin
     begin
-      C:=C+'#$'+IntToHex(ord(S[I]),2);
+      Insert('#$'+IntToHex(ord(S[I]),2),C,Length(C)+1);
     end;
     end;
   PaletteToStr:=C;
   PaletteToStr:=C;
 end;
 end;
@@ -622,7 +622,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.2  2001-08-05 02:01:48  peter
+  Revision 1.3  2001-08-12 00:04:50  pierre
+   * some speed improvements for string operations
+
+  Revision 1.2  2001/08/05 02:01:48  peter
     * FVISION define to compile with fvision units
     * FVISION define to compile with fvision units
 
 
   Revision 1.1  2001/08/04 11:30:23  peter
   Revision 1.1  2001/08/04 11:30:23  peter

+ 8 - 3
ide/fpusrscr.pas

@@ -259,8 +259,10 @@ begin
     W:=GetLineStartOfs(Line);
     W:=GetLineStartOfs(Line);
     for X:=0 to GetWidth-1 do
     for X:=0 to GetWidth-1 do
      begin
      begin
-       Text:=Text+chr(VBuffer^[W+X*2]);
-       Attr:=Attr+chr(VBuffer^[W+X*2+1]);
+       {Text:=Text+chr(VBuffer^[W+X*2]);
+       Attr:=Attr+chr(VBuffer^[W+X*2+1]);}
+       System.Insert(chr(VBuffer^[W+X*2]),Text,Length(Text)+1);
+       System.Insert(chr(VBuffer^[W+X*2+1]),Attr,Length(Attr)+1);
      end;
      end;
   end;
   end;
 end;
 end;
@@ -832,7 +834,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.1  2001-08-04 11:30:24  peter
+  Revision 1.2  2001-08-12 00:04:50  pierre
+   * some speed improvements for string operations
+
+  Revision 1.1  2001/08/04 11:30:24  peter
     * ide works now with both compiler versions
     * ide works now with both compiler versions
 
 
   Revision 1.1.2.10  2001/06/14 09:15:16  pierre
   Revision 1.1.2.10  2001/06/14 09:15:16  pierre

+ 23 - 15
ide/wansi.pas

@@ -90,8 +90,8 @@ type
        procedure   FillScreen(B: byte); virtual;
        procedure   FillScreen(B: byte); virtual;
        procedure   ClrEol; virtual;
        procedure   ClrEol; virtual;
        procedure   GotoXY(X,Y: integer); virtual;
        procedure   GotoXY(X,Y: integer); virtual;
-       procedure   Write(S: string); virtual;
-       procedure   WriteLn(S: string); virtual;
+       procedure   Write(Const S: string); virtual;
+       procedure   WriteLn(Const S: string); virtual;
        procedure   WriteChar(C: char); virtual;
        procedure   WriteChar(C: char); virtual;
        procedure   DelLine(LineCount: integer); virtual;
        procedure   DelLine(LineCount: integer); virtual;
        procedure   InsLine(LineCount: integer); virtual;
        procedure   InsLine(LineCount: integer); virtual;
@@ -183,8 +183,8 @@ type
        function    LoadFile(const FileName: string): boolean;
        function    LoadFile(const FileName: string): boolean;
        procedure   Draw; virtual;
        procedure   Draw; virtual;
        destructor  Done; virtual;
        destructor  Done; virtual;
-       procedure   Write(S: string); virtual;
-       procedure   WriteLn(S: string); virtual;
+       procedure   Write(Const S: string); virtual;
+       procedure   WriteLn(Const S: string); virtual;
        procedure   Lock; virtual;
        procedure   Lock; virtual;
        procedure   UnLock; virtual;
        procedure   UnLock; virtual;
        procedure   ChangeBounds(var Bounds: TRect); virtual;
        procedure   ChangeBounds(var Bounds: TRect); virtual;
@@ -217,8 +217,8 @@ type
        function    LoadFile(const FileName: string): boolean;
        function    LoadFile(const FileName: string): boolean;
        procedure   Draw; virtual;
        procedure   Draw; virtual;
        destructor  Done; virtual;
        destructor  Done; virtual;
-       procedure   Write(S: string); virtual;
-       procedure   WriteLn(S: string); virtual;
+       procedure   Write(Const S: string); virtual;
+       procedure   WriteLn(Const S: string); virtual;
        procedure   Lock; virtual;
        procedure   Lock; virtual;
        procedure   UnLock; virtual;
        procedure   UnLock; virtual;
        procedure   ChangeBounds(var Bounds: TRect); virtual;
        procedure   ChangeBounds(var Bounds: TRect); virtual;
@@ -294,7 +294,7 @@ begin
   Abstract;
   Abstract;
 end;
 end;
 
 
-procedure TConsoleObject.Write(S: string); {assembler;
+procedure TConsoleObject.Write(Const S: string); {assembler;
 asm
 asm
   push   ds
   push   ds
   lds    si, S
   lds    si, S
@@ -321,9 +321,9 @@ begin
   for I:=1 to Len do ProcessChar(S[I]);
   for I:=1 to Len do ProcessChar(S[I]);
 end;
 end;
 
 
-procedure TConsoleObject.WriteLn(S: string);
+procedure TConsoleObject.WriteLn(Const S: string);
 begin
 begin
-  Write(S+#10);
+  Write(S);Write(#10);
 end;
 end;
 
 
 procedure TConsoleObject.DelLine(LineCount: integer);
 procedure TConsoleObject.DelLine(LineCount: integer);
@@ -542,7 +542,12 @@ begin
                  'M'     : if ANSIParam='' then DelLine(1)
                  'M'     : if ANSIParam='' then DelLine(1)
                                            else DelLine(GetANSIParam);
                                            else DelLine(GetANSIParam);
                  'm'     : while ANSIParam<>'' do SetAttr(GetANSIParam);
                  'm'     : while ANSIParam<>'' do SetAttr(GetANSIParam);
-            else begin ANSIParam:=ANSIParam+C; ANSIDone:=false; end;
+            else
+              begin
+                {ANSIParam:=ANSIParam+C;}
+                System.Insert(C,AnsiParam,Length(AnsiParam)+1);
+                ANSIDone:=false;
+              end;
             end;
             end;
             if ANSIDone then
             if ANSIDone then
                begin
                begin
@@ -794,13 +799,13 @@ begin
           end;
           end;
 end;
 end;
 
 
-procedure TANSIView.Write(S: string);
+procedure TANSIView.Write(Const S: string);
 begin
 begin
   Console^.Write(S);
   Console^.Write(S);
   DrawView;
   DrawView;
 end;
 end;
 
 
-procedure TANSIView.WriteLn(S: string);
+procedure TANSIView.WriteLn(Const S: string);
 begin
 begin
   Console^.WriteLn(S);
   Console^.WriteLn(S);
   DrawView;
   DrawView;
@@ -999,13 +1004,13 @@ begin
           end;
           end;
 end;
 end;
 
 
-procedure TANSIBackground.Write(S: string);
+procedure TANSIBackground.Write(Const S: string);
 begin
 begin
   Console^.Write(S);
   Console^.Write(S);
   DrawView;
   DrawView;
 end;
 end;
 
 
-procedure TANSIBackground.WriteLn(S: string);
+procedure TANSIBackground.WriteLn(Const S: string);
 begin
 begin
   Console^.WriteLn(S);
   Console^.WriteLn(S);
   DrawView;
   DrawView;
@@ -1047,7 +1052,10 @@ end;
 END.
 END.
 {
 {
  $Log$
  $Log$
- Revision 1.1  2001-08-04 11:30:25  peter
+ Revision 1.2  2001-08-12 00:04:50  pierre
+  * some speed improvements for string operations
+
+ Revision 1.1  2001/08/04 11:30:25  peter
    * ide works now with both compiler versions
    * ide works now with both compiler versions
 
 
  Revision 1.1.2.5  2001/03/06 22:39:31  pierre
  Revision 1.1.2.5  2001/03/06 22:39:31  pierre

+ 16 - 4
ide/wutils.pas

@@ -395,8 +395,16 @@ begin
 end;
 end;
 
 
 function Trim(const S: string): string;
 function Trim(const S: string): string;
+var
+  i,j : longint;
 begin
 begin
-  Trim:=RTrim(LTrim(S));
+  i:=1;
+  while (i<length(s)) and (s[i]=' ') do
+   inc(i);
+  j:=length(s);
+  while (j>0) and (s[j]=' ') do
+   dec(j);
+  Trim:=Copy(S,i,j-i+1);
 end;
 end;
 
 
 function IntToStr(L: longint): string;
 function IntToStr(L: longint): string;
@@ -464,10 +472,11 @@ begin
   S:='';
   S:='';
   R:=L; if R<0 then begin R:=R+2147483647+2147483647+2; end;
   R:=L; if R<0 then begin R:=R+2147483647+2147483647+2; end;
   repeat
   repeat
-    S:=HexNums[ModF(R,16)+1]+S;
+    Insert(HexNums[ModF(R,16)+1],S,1);
     R:=DivF(R,16);
     R:=DivF(R,16);
   until R=0;
   until R=0;
-  while length(S)<MinLen do S:='0'+S;
+  while length(S)<MinLen do
+    Insert('0',S,1);
   IntToHex:=S;
   IntToHex:=S;
 end;
 end;
 
 
@@ -1220,7 +1229,10 @@ BEGIN
 END.
 END.
 {
 {
   $Log$
   $Log$
-  Revision 1.2  2001-08-05 02:01:49  peter
+  Revision 1.3  2001-08-12 00:04:50  pierre
+   * some speed improvements for string operations
+
+  Revision 1.2  2001/08/05 02:01:49  peter
     * FVISION define to compile with fvision units
     * FVISION define to compile with fvision units
 
 
   Revision 1.1  2001/08/04 11:30:26  peter
   Revision 1.1  2001/08/04 11:30:26  peter