Bladeren bron

* made ifthen() declaration in strutils Delphi-compatible (removed overloads
that cause various problems, added "overload" directive so it gets
overloaded next to the routines in the "math" unit) (based on patch
by Alexander S. Klenin, mantis #13619)
- removed "inline" from that function because all the reference increasing/
decreasing in its body mainly cause code bloat and little if any speed
increase

git-svn-id: trunk@13084 -

Jonas Maebe 16 jaren geleden
bovenliggende
commit
445c842db3
3 gewijzigde bestanden met toevoegingen van 13 en 18 verwijderingen
  1. 1 0
      .gitattributes
  2. 2 18
      rtl/objpas/strutils.pp
  3. 10 0
      tests/webtbs/tw13619.pp

+ 1 - 0
.gitattributes

@@ -8842,6 +8842,7 @@ tests/webtbs/tw13563.pp svneol=native#text/plain
 tests/webtbs/tw13583.pp svneol=native#text/plain
 tests/webtbs/tw13596.pp svneol=native#text/plain
 tests/webtbs/tw13596a.pp svneol=native#text/plain
+tests/webtbs/tw13619.pp svneol=native#text/plain
 tests/webtbs/tw13622.pp svneol=native#text/plain
 tests/webtbs/tw13628a.pp svneol=native#text/plain
 tests/webtbs/tw13628b.pp svneol=native#text/plain

+ 2 - 18
rtl/objpas/strutils.pp

@@ -54,9 +54,7 @@ Function ReverseString(const AText: string): string;
 Function AnsiReverseString(const AText: AnsiString): AnsiString;inline;
 Function StuffString(const AText: string; AStart, ALength: Cardinal;  const ASubText: string): string;
 Function RandomFrom(const AValues: array of string): string; overload;
-Function IfThen(AValue: Boolean; const ATrue: string; AFalse: string): string;inline;
-Function IfThen(AValue: Boolean; const ATrue: string): string;inline; // ; AFalse: string = ''
-Function IfThen(AValue: Boolean; const ATrue: shortString ; const Afalse: shortString ='') :shortString;  inline;
+Function IfThen(AValue: Boolean; const ATrue: string; const AFalse: string = ''): string; overload;
 
 { ---------------------------------------------------------------------
     VB emulations.
@@ -396,7 +394,7 @@ begin
   result:=Avalues[random(High(AValues)+1)];
 end;
 
-Function IfThen(AValue: Boolean; const ATrue: string; AFalse: string): string;inline;
+Function IfThen(AValue: Boolean; const ATrue: string; const AFalse: string = ''): string; overload;
 
 begin
   if avalue then
@@ -405,20 +403,6 @@ begin
     result:=afalse;
 end;
 
-Function IfThen(AValue: Boolean; const ATrue: string): string;inline; // ; AFalse: string = ''
-
-begin
-  if avalue then
-    result:=atrue
-  else
-    result:='';
-end;
-
-Function IfThen(AValue:boolean;const ATrue:shortString ; const AFalse:shortString ='') :shortString;  inline;
-begin
-  if AValue then result:=ATrue else result:=AFalse;
-end;
-
 { ---------------------------------------------------------------------
     VB emulations.
   ---------------------------------------------------------------------}

+ 10 - 0
tests/webtbs/tw13619.pp

@@ -0,0 +1,10 @@
+uses
+  Math, StrUtils;
+begin
+  if (IfThen(1 > 2, 1, 2) <> 2) then
+    halt(1);
+  if (IfThen(1 > 2, '1', '2') <> '2') then
+    halt(2);
+  if (IfThen(1 > 2, '123', '456') <> '456') then
+    halt(3);
+end.