* Avoid memory allocation and string copying

This commit is contained in:
daniel 2004-02-21 22:08:46 +00:00
parent b23904af2a
commit 3ea87ad054

View File

@ -106,6 +106,7 @@ implementation
resultset : Tconstset; resultset : Tconstset;
i : longint; i : longint;
b : boolean; b : boolean;
c1,c2 :char;
s1,s2 : pchar; s1,s2 : pchar;
ws1,ws2 : pcompilerwidestring; ws1,ws2 : pcompilerwidestring;
l1,l2 : longint; l1,l2 : longint;
@ -468,41 +469,41 @@ implementation
{ concating strings ? } { concating strings ? }
concatstrings:=false; concatstrings:=false;
s1:=nil;
s2:=nil;
if (lt=ordconstn) and (rt=ordconstn) and if (lt=ordconstn) and (rt=ordconstn) and
is_char(ld) and is_char(rd) then is_char(ld) and is_char(rd) then
begin begin
s1:=strpnew(char(byte(tordconstnode(left).value))); c1:=char(byte(tordconstnode(left).value));
s2:=strpnew(char(byte(tordconstnode(right).value)));
l1:=1; l1:=1;
c2:=char(byte(tordconstnode(right).value));
l2:=1; l2:=1;
s1:=@c1;
s2:=@c2;
concatstrings:=true; concatstrings:=true;
end end
else else if (lt=stringconstn) and (rt=ordconstn) and is_char(rd) then
if (lt=stringconstn) and (rt=ordconstn) and is_char(rd) then
begin begin
s1:=tstringconstnode(left).getpcharcopy; s1:=tstringconstnode(left).value_str;
l1:=tstringconstnode(left).len; l1:=tstringconstnode(left).len;
s2:=strpnew(char(byte(tordconstnode(right).value))); c2:=char(byte(tordconstnode(right).value));
s2:=@c2;
l2:=1; l2:=1;
concatstrings:=true; concatstrings:=true;
end end
else else if (lt=ordconstn) and (rt=stringconstn) and is_char(ld) then
if (lt=ordconstn) and (rt=stringconstn) and is_char(ld) then
begin begin
s1:=strpnew(char(byte(tordconstnode(left).value))); c1:=char(byte(tordconstnode(left).value));
l1:=1; l1:=1;
s2:=tstringconstnode(right).getpcharcopy; s1:=@c1;
s2:=tstringconstnode(right).value_str;
l2:=tstringconstnode(right).len; l2:=tstringconstnode(right).len;
concatstrings:=true; concatstrings:=true;
end end
else if (lt=stringconstn) and (rt=stringconstn) then else if (lt=stringconstn) and (rt=stringconstn) then
begin begin
s1:=tstringconstnode(left).getpcharcopy; s1:=tstringconstnode(left).value_str;
l1:=tstringconstnode(left).len; l1:=tstringconstnode(left).len;
s2:=tstringconstnode(right).getpcharcopy; s2:=tstringconstnode(right).value_str;
l2:=tstringconstnode(right).len; l2:=tstringconstnode(right).len;
concatstrings:=true; concatstrings:=true;
end; end;
@ -524,8 +525,6 @@ implementation
unequaln : unequaln :
t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)<>0),booltype,true); t:=cordconstnode.create(byte(compareansistrings(s1,s2,l1,l2)<>0),booltype,true);
end; end;
ansistringdispose(s1,l1);
ansistringdispose(s2,l2);
result:=t; result:=t;
exit; exit;
end; end;
@ -1914,7 +1913,10 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.111 2004-02-20 21:55:59 peter Revision 1.112 2004-02-21 22:08:46 daniel
* Avoid memory allocation and string copying
Revision 1.111 2004/02/20 21:55:59 peter
* procvar cleanup * procvar cleanup
Revision 1.110 2004/02/05 01:24:08 florian Revision 1.110 2004/02/05 01:24:08 florian