Browse Source

* made inster(string,string,index) a bit faster
+ overloaded insert(char,string,index)

Jonas Maebe 26 years ago
parent
commit
f7b137cdef
2 changed files with 26 additions and 3 deletions
  1. 20 2
      rtl/inc/sstrings.inc
  2. 6 1
      rtl/inc/systemh.inc

+ 20 - 2
rtl/inc/sstrings.inc

@@ -60,7 +60,21 @@ begin
    dec(index)
    dec(index)
   else
   else
    index:=0;
    index:=0;
-  s:=Copy(s,1,Index)+source+Copy(s,Index+1,length(s));
+{  s:=Copy(s,1,Index)+source+Copy(s,Index+1,length(s));}
+  move(s[Index+1],s[Index+Length(Source)+1], Length(s)-Index);
+  move(Source[1],s[Index+1],Length(Source));
+  Inc(Byte(s[0]),Byte(source[0]));
+end;
+
+procedure insert(source : Char;var s : shortstring;index : StrLenInt);
+begin
+  if index>1 then
+   dec(index)
+  else
+   index:=0;
+  move(s[Index+1],s[Index+2], Length(s)-Index);
+  s[Index+1] := Source;
+  Inc(Byte(s[0]));
 end;
 end;
 
 
 
 
@@ -937,7 +951,11 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.17  1998-12-15 22:43:02  peter
+  Revision 1.18  1999-01-11 19:26:55  jonas
+    * made inster(string,string,index) a bit faster
+    + overloaded insert(char,string,index)
+
+  Revision 1.17  1998/12/15 22:43:02  peter
     * removed temp symbols
     * removed temp symbols
 
 
   Revision 1.16  1998/11/05 10:29:34  pierre
   Revision 1.16  1998/11/05 10:29:34  pierre

+ 6 - 1
rtl/inc/systemh.inc

@@ -188,6 +188,7 @@ function strlen(p:pchar):longint;
 Function  Copy(const s:shortstring;index:StrLenInt;count:StrLenInt):shortstring;
 Function  Copy(const s:shortstring;index:StrLenInt;count:StrLenInt):shortstring;
 Procedure Delete(Var s:shortstring;index:StrLenInt;count:StrLenInt);
 Procedure Delete(Var s:shortstring;index:StrLenInt;count:StrLenInt);
 Procedure Insert(const source:shortstring;Var s:shortstring;index:StrLenInt);
 Procedure Insert(const source:shortstring;Var s:shortstring;index:StrLenInt);
+Procedure Insert(source:Char;Var s:shortstring;index:StrLenInt);
 Function  Pos(const substr:shortstring;const s:shortstring):StrLenInt;
 Function  Pos(const substr:shortstring;const s:shortstring):StrLenInt;
 Function  Pos(C:Char;const s:shortstring):StrLenInt;
 Function  Pos(C:Char;const s:shortstring):StrLenInt;
 Procedure SetLength(var s:shortstring;len:StrLenInt);
 Procedure SetLength(var s:shortstring;len:StrLenInt);
@@ -430,7 +431,11 @@ const
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.46  1998-12-28 15:50:48  peter
+  Revision 1.47  1999-01-11 19:26:53  jonas
+    * made inster(string,string,index) a bit faster
+    + overloaded insert(char,string,index)
+
+  Revision 1.46  1998/12/28 15:50:48  peter
     + stdout, which is needed when you write something in the system unit
     + stdout, which is needed when you write something in the system unit
       to the screen. Like the runtime error
       to the screen. Like the runtime error