diff options
author | michael <michael@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2018-08-04 08:05:31 +0000 |
---|---|---|
committer | michael <michael@3ad0048d-3df7-0310-abae-a5850022a9f2> | 2018-08-04 08:05:31 +0000 |
commit | 71d01bf714ccf75ac7b505856e7387e53176d820 (patch) | |
tree | 977a332cd27e89eac0d7ef82734999b60272df40 /packages/regexpr/src | |
parent | 6b7e070cb75a1680aa34734f29284faf71336a4a (diff) | |
download | fpc-71d01bf714ccf75ac7b505856e7387e53176d820.tar.gz |
* Fix bug 34087: Small optimization of StrlComp
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@39563 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/regexpr/src')
-rw-r--r-- | packages/regexpr/src/regexpr.pas | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/packages/regexpr/src/regexpr.pas b/packages/regexpr/src/regexpr.pas index b5f9a962a3..64dcd1178f 100644 --- a/packages/regexpr/src/regexpr.pas +++ b/packages/regexpr/src/regexpr.pas @@ -760,13 +760,16 @@ function StrLComp (Str1, Str2: PRegExprChar; MaxLen: PtrUInt): PtrInt; var S1, S2: RegExprString; - begin S1 := Str1; S2 := Str2; - if Copy (S1, 1, MaxLen) > Copy (S2, 1, MaxLen) then + if Length(S1) > MaxLen then + SetLength(S1, MaxLen); + if Length(S2) > MaxLen then + SetLength(S2, MaxLen); + if S1 > S2 then Result := 1 - else if Copy (S1, 1, MaxLen) < Copy (S2, 1, MaxLen) then + else if S2 < S2 then Result := -1 else Result := 0; |