View Issue Details

IDProjectCategoryView StatusLast Update
0034087FPCPackagespublic2018-08-04 18:14
ReporterAlexey Tor.Assigned ToMichael Van Canneyt 
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product VersionProduct Build 
Target Version3.2.0Fixed in Version3.1.1 
Summary0034087: RegExpr: optimized func
Descriptioni suggest optimization for function to not calc Copy() two times for same args.

function StrLComp (Str1, Str2: PRegExprChar; MaxLen: PtrUInt): PtrInt;
var
  S1, S2: RegExprString;
begin
  S1 := Str1;
  S2 := Str2;
  if Length(S1) > MaxLen then
    SetLength(S1, MaxLen);
  if Length(S2) > MaxLen then
    SetLength(S2, MaxLen);
  if S1 > S2 then
    Result := 1
  else if S2 < S2 then
    Result := -1
  else
    Result := 0;
end; { function StrLComp
--------------------------------------------------------------}


TagsNo tags attached.
Fixed in Revision39570
FPCOldBugId
FPCTarget
Attached Files

Activities

Alexey Tor.

2018-08-03 21:19

reporter   ~0109865

ops, mistake: "if S2 < S2" must be "if S1 < S2"

Michael Van Canneyt

2018-08-04 10:06

administrator   ~0109874

Implemented as suggested. Thanks for the suggestion!

Alexey Tor.

2018-08-04 10:16

reporter   ~0109875

Alert. i had a mistake, see my comment above. "if S2 < S2".

Alexey Tor.

2018-08-04 10:30

reporter   ~0109876

Last edited: 2018-08-04 10:35

View 2 revisions

And: why at all StrLComp is written here?
SysUtils has StrLComp for PChar / PWideChar.
It gets not +1/-1/0 but +N/-N/0, still you can use SysUtils.StrLComp, because regexpr only checks for 0 result.

And these also in SysUtils
  StrPCopy()
  StrLCopy();
  StrLen()
  StrPos()
  StrScan()

Michael Van Canneyt

2018-08-04 10:44

administrator   ~0109878

fixed in 39567.

I suspect these functions are there because of support for other compilers (D7 and older etc).

I suppose it is OK to remove them now (and the support for other compilers, the Delphi detection mechanism is completely out of date),

But then I would need to be sure that the class will still react the same,
so I need a testsuite to demonstrate this convincingly :(

Alexey Tor.

2018-08-04 11:05

reporter   ~0109879

I dont know how to write this testsuite. I just tested w/o these duplicates, regex find/replace works in CudaText.
(mass replace from \w+ to [$0] )

Michael Van Canneyt

2018-08-04 14:13

administrator   ~0109883

Removed duplicated functions from sysutils.
It seemed a lot of them were not even used in the code :(

Issue History

Date Modified Username Field Change
2018-08-03 21:18 Alexey Tor. New Issue
2018-08-03 21:19 Alexey Tor. Note Added: 0109865
2018-08-03 22:25 Michael Van Canneyt Assigned To => Michael Van Canneyt
2018-08-03 22:25 Michael Van Canneyt Status new => assigned
2018-08-04 10:06 Michael Van Canneyt Fixed in Revision => 39563
2018-08-04 10:06 Michael Van Canneyt Note Added: 0109874
2018-08-04 10:06 Michael Van Canneyt Status assigned => resolved
2018-08-04 10:06 Michael Van Canneyt Fixed in Version => 3.1.1
2018-08-04 10:06 Michael Van Canneyt Resolution open => fixed
2018-08-04 10:06 Michael Van Canneyt Target Version => 3.2.0
2018-08-04 10:16 Alexey Tor. Note Added: 0109875
2018-08-04 10:16 Alexey Tor. Status resolved => feedback
2018-08-04 10:16 Alexey Tor. Resolution fixed => reopened
2018-08-04 10:30 Alexey Tor. Note Added: 0109876
2018-08-04 10:30 Alexey Tor. Status feedback => assigned
2018-08-04 10:35 Alexey Tor. Note Edited: 0109876 View Revisions
2018-08-04 10:44 Michael Van Canneyt Note Added: 0109878
2018-08-04 10:44 Michael Van Canneyt Status assigned => resolved
2018-08-04 10:44 Michael Van Canneyt Resolution reopened => fixed
2018-08-04 11:05 Alexey Tor. Note Added: 0109879
2018-08-04 11:05 Alexey Tor. Status resolved => feedback
2018-08-04 11:05 Alexey Tor. Resolution fixed => reopened
2018-08-04 14:13 Michael Van Canneyt Fixed in Revision 39563 => 39570
2018-08-04 14:13 Michael Van Canneyt Note Added: 0109883
2018-08-04 14:13 Michael Van Canneyt Status feedback => resolved
2018-08-04 14:13 Michael Van Canneyt Resolution reopened => fixed
2018-08-04 18:14 Alexey Tor. Status resolved => closed