浏览代码

* Som optimizations. Fixes issue #40380

Michaël Van Canneyt 1 月之前
父节点
当前提交
b3cccd8876

+ 8 - 8
packages/fcl-base/src/custapp.pp

@@ -186,22 +186,22 @@ begin
 end;
 {$endif darwin}
 
-Procedure SysGetEnvironmentList(List : TStrings;NamesOnly : Boolean);
+Procedure SysGetEnvironmentList(List : TStrings; NamesOnly : Boolean);
 
 var
-   s : string;
-   i,j,count : longint;
+   S : String;
+   I,J,Count : Integer;
 
 begin
-  count:=GetEnvironmentVariableCount;
-  for j:=1 to count  do
+  Count:=GetEnvironmentVariableCount;
+  for J:=1 to Count do
     begin
-    s:=GetEnvironmentString(j);
+    S:=GetEnvironmentString(J);
     If NamesOnly then
       begin
-      I:=pos('=',s);
+      I:=Pos('=',S);
       If (I>1) then
-        S:=Copy(S,1,I-1);
+        SetLength(S,I-1);
       end;
     List.Add(S);
     end;

+ 2 - 2
packages/fcl-base/src/go32v2/custapp.inc

@@ -13,7 +13,7 @@
 
  **********************************************************************}
 
-Procedure SysGetEnvironmentList(List : TStrings;NamesOnly : Boolean);
+Procedure SysGetEnvironmentList(List : TStrings; NamesOnly : Boolean);
 
 Var
   P : PPAnsiChar;
@@ -31,7 +31,7 @@ begin
         begin
         I:=Pos('=',S);
         If (I>1) then
-          S:=Copy(S,1,I-1);
+          SetLength(S,I-1);
         end;
       List.Add(S);
       Inc(P);

+ 3 - 3
packages/fcl-base/src/netwlibc/custapp.inc

@@ -13,7 +13,7 @@
 
  **********************************************************************}
 
-Procedure SysGetEnvironmentList(List : TStrings;NamesOnly : Boolean);
+Procedure SysGetEnvironmentList(List : TStrings; NamesOnly : Boolean);
 
 Var
   P : PPAnsiChar;
@@ -30,8 +30,8 @@ begin
       If NamesOnly then
         begin
         I:=Pos('=',S);
-        If (I>0) then
-          S:=Copy(S,1,I-1);
+        If (I>1) then
+          SetLength(S,I-1);
         end;
       List.Add(S);
       Inc(P);

+ 3 - 3
packages/fcl-base/src/os2/custapp.inc

@@ -30,10 +30,10 @@ begin
 end;
 
 
-procedure SysGetEnvironmentList(List : TStrings;NamesOnly : Boolean);
+procedure SysGetEnvironmentList(List : TStrings; NamesOnly : Boolean);
 
 Var
-  S : ;
+  S : String;
   J,I : Integer;
 
 begin
@@ -45,7 +45,7 @@ begin
       begin
       I:=Pos('=',S);
       If (I>1) then
-        S:=Copy(S,1,I-1);
+        SetLength(S,I-1);
       end;
     List.Add(S);
     end;