mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 07:46:00 +02:00
+ Pass hash also for speed reasons.
This commit is contained in:
parent
77f10694a1
commit
1ebb362a0d
@ -57,9 +57,9 @@ unit objpas;
|
|||||||
|
|
||||||
{$ifdef HasResourceStrings}
|
{$ifdef HasResourceStrings}
|
||||||
{ Resourcestring support }
|
{ Resourcestring support }
|
||||||
Function GetResourceString(Const Name : ShortString) : AnsiString;
|
Function GetResourceString(Hash : Longint;Const Name : ShortString) : AnsiString;
|
||||||
Procedure ResetResourceTables;
|
Procedure ResetResourceTables;
|
||||||
Function SetResourceString(Const Name : Shortstring; Const Value : AnsiString) : Boolean;
|
Function SetResourceString(Hash : Longint;Const Name : Shortstring; Const Value : AnsiString) : Boolean;
|
||||||
{$endif}
|
{$endif}
|
||||||
|
|
||||||
|
|
||||||
@ -260,14 +260,13 @@ begin
|
|||||||
CalcStringHashValue:=Hash;
|
CalcStringHashValue:=Hash;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function FindIndex (Const Value : Shortstring) : Longint;
|
Function FindIndex (Hash : longint;Const Value : Shortstring) : Longint;
|
||||||
|
|
||||||
Var
|
Var
|
||||||
I,Hash : longint;
|
I : longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
// Linear search, later we can implement binary search.
|
// Linear search, later we can implement binary search.
|
||||||
Hash:=CalcStringHashValue(Value);
|
|
||||||
Result:=-1;
|
Result:=-1;
|
||||||
With ResourceStringTable do
|
With ResourceStringTable do
|
||||||
For I:=0 to Count-1 do
|
For I:=0 to Count-1 do
|
||||||
@ -289,25 +288,21 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function GetResourceString(Const Name : ShortString) : AnsiString;[Public,Alias : 'FPC_GETRESOURCESTRING'];
|
Function GetResourceString(Hash : longint;Const Name : ShortString) : AnsiString;[Public,Alias : 'FPC_GETRESOURCESTRING'];
|
||||||
|
|
||||||
Var I : longint;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
I:=FindIndex(Name);
|
Hash:=FindIndex(Hash,Name);
|
||||||
If I<>-1 then
|
If Hash<>-1 then
|
||||||
Result:=ResourceStringTable.ResRec[I].CurrentValue
|
Result:=ResourceStringTable.ResRec[Hash].CurrentValue
|
||||||
else
|
else
|
||||||
Result:='';
|
Result:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Function SetResourceString(Const Name : ShortString; Const Value : AnsiString) : Boolean;
|
Function SetResourceString(Hash : Longint;Const Name : ShortString; Const Value : AnsiString) : Boolean;
|
||||||
|
|
||||||
Var Hash : Longint;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Hash:=FindIndex(Name);
|
Hash:=FindIndex(Hash,Name);
|
||||||
Result:=Hash<>-1;
|
Result:=Hash<>-1;
|
||||||
If Result then
|
If Result then
|
||||||
ResourceStringTable.ResRec[Hash].CurrentValue:=Value;
|
ResourceStringTable.ResRec[Hash].CurrentValue:=Value;
|
||||||
@ -338,7 +333,10 @@ end.
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.31 1999-08-15 21:02:56 michael
|
Revision 1.32 1999-08-15 21:28:57 michael
|
||||||
|
+ Pass hash also for speed reasons.
|
||||||
|
|
||||||
|
Revision 1.31 1999/08/15 21:02:56 michael
|
||||||
+ Changed resource string mechanism to use names.
|
+ Changed resource string mechanism to use names.
|
||||||
|
|
||||||
Revision 1.30 1999/08/15 18:56:13 michael
|
Revision 1.30 1999/08/15 18:56:13 michael
|
||||||
|
Loading…
Reference in New Issue
Block a user