Browse Source

* Patch with some micro-optimizations. Fixes issue #40378

Michaël Van Canneyt 2 years ago
parent
commit
8539a8b727
1 changed files with 7 additions and 7 deletions
  1. 7 7
      packages/fcl-base/src/uriparser.pp

+ 7 - 7
packages/fcl-base/src/uriparser.pp

@@ -207,7 +207,7 @@ begin
     Result.Bookmark := Copy(s, i + 1, MaxInt);
     Result.Bookmark := Copy(s, i + 1, MaxInt);
     if Decode then
     if Decode then
       Result.Bookmark:=Unescape(Result.Bookmark);
       Result.Bookmark:=Unescape(Result.Bookmark);
-    s := Copy(s, 1, i - 1);
+    SetLength(s, i - 1);
   end;
   end;
 
 
   // Extract the params
   // Extract the params
@@ -218,7 +218,7 @@ begin
     Result.Params := Copy(s, i + 1, MaxInt);
     Result.Params := Copy(s, i + 1, MaxInt);
     if Decode then
     if Decode then
       Result.Params:=Unescape(Result.Params);
       Result.Params:=Unescape(Result.Params);
-    s := Copy(s, 1, i - 1);
+    SetLength(s, i - 1);
   end;
   end;
 
 
   // extract authority
   // extract authority
@@ -248,7 +248,7 @@ begin
       if Decode then
       if Decode then
         Result.Document:=Unescape(Result.Document);
         Result.Document:=Unescape(Result.Document);
       if (Result.Document <> '.') and (Result.Document <> '..') then
       if (Result.Document <> '.') and (Result.Document <> '..') then
-        s := Copy(s, 1, i)
+        SetLength(s, i)
       else
       else
         Result.Document := '';
         Result.Document := '';
       break;
       break;
@@ -287,7 +287,7 @@ begin
     if PortValid then
     if PortValid then
     begin
     begin
       Result.Port := StrToInt(Copy(Authority, i + 1, MaxInt));
       Result.Port := StrToInt(Copy(Authority, i + 1, MaxInt));
-      Authority := Copy(Authority, 1, i - 1);
+      SetLength(Authority, i - 1);
     end;
     end;
   end;
   end;
 
 
@@ -296,11 +296,11 @@ begin
   i := Pos('@', Authority);
   i := Pos('@', Authority);
   if i > 0 then
   if i > 0 then
   begin
   begin
-    Result.Host := Copy(Authority, i+1, MaxInt);
-    Delete(Authority, i, MaxInt);
+    Result.Host := Copy(Authority, i + 1, MaxInt);
+    SetLength(Authority, i - 1);
 
 
     // Extract username and password
     // Extract username and password
-    if Length(Authority) > 0 then
+    if Authority <> '' then
     begin
     begin
       i := Pos(':', Authority);
       i := Pos(':', Authority);
       if i = 0 then
       if i = 0 then