Browse Source

* remove unneeded checks in generic string routines, resolves #40816

florian 1 year ago
parent
commit
8d3a9c3dda
1 changed files with 5 additions and 6 deletions
  1. 5 6
      rtl/inc/genstr.inc

+ 5 - 6
rtl/inc/genstr.inc

@@ -248,8 +248,8 @@
         counter := 0;
         counter := 0;
        While str1[counter] = str2[counter] do
        While str1[counter] = str2[counter] do
        Begin
        Begin
-         if (str2[counter] = #0) or (str1[counter] = #0) then
-            break;
+         if str1[counter] = #0 then
+           break;
          Inc(counter);
          Inc(counter);
        end;
        end;
        StrComp := ord(str1[counter]) - ord(str2[counter]);
        StrComp := ord(str1[counter]) - ord(str2[counter]);
@@ -268,7 +268,7 @@
         c2 := upcase(str2[counter]);
         c2 := upcase(str2[counter]);
        While c1 = c2 do
        While c1 = c2 do
        Begin
        Begin
-         if (c1 = #0) or (c2 = #0) then break;
+         if c1 = #0 then break;
          Inc(counter);
          Inc(counter);
          c1 := upcase(str1[counter]);
          c1 := upcase(str1[counter]);
          c2 := upcase(str2[counter]);
          c2 := upcase(str2[counter]);
@@ -296,7 +296,7 @@
          if (c1 = #0) or (c2 = #0) then break;
          if (c1 = #0) or (c2 = #0) then break;
          Inc(counter);
          Inc(counter);
       Until (c1 <> c2) or (counter >= L);
       Until (c1 <> c2) or (counter >= L);
-       StrLComp := ord(c1) - ord(c2);
+      StrLComp := ord(c1) - ord(c2);
      end;
      end;
 {$endif FPC_UNIT_HAS_STRLCOMP}
 {$endif FPC_UNIT_HAS_STRLCOMP}
 
 
@@ -319,7 +319,6 @@
          if (c1 = #0) or (c2 = #0) then break;
          if (c1 = #0) or (c2 = #0) then break;
          Inc(counter);
          Inc(counter);
       Until (c1 <> c2) or (counter >= L);
       Until (c1 <> c2) or (counter >= L);
-       StrLIComp := ord(c1) - ord(c2);
+      StrLIComp := ord(c1) - ord(c2);
      end;
      end;
 {$endif FPC_UNIT_HAS_STRLICOMP}
 {$endif FPC_UNIT_HAS_STRLICOMP}
-