mirror of https://gitlab.com/basile.b/dexed.git
dcd integration, cache imports in a hashset
This commit is contained in:
parent
7aae871188
commit
d92390471d
|
@ -31,7 +31,7 @@ type
|
||||||
|
|
||||||
TCECompiler = (dmd, gdc, ldc);
|
TCECompiler = (dmd, gdc, ldc);
|
||||||
|
|
||||||
// function used as hash in gXXX sets & maps
|
// function used as string hasher in fcl-stl
|
||||||
TStringHash = class
|
TStringHash = class
|
||||||
class function hash(const key: string; maxBucketsPow2: longint): longint;
|
class function hash(const key: string; maxBucketsPow2: longint): longint;
|
||||||
end;
|
end;
|
||||||
|
@ -39,12 +39,16 @@ type
|
||||||
// HashMap for TValue by string
|
// HashMap for TValue by string
|
||||||
generic TStringHashMap<TValue> = class(specialize THashmap<string, TValue, TStringHash>);
|
generic TStringHashMap<TValue> = class(specialize THashmap<string, TValue, TStringHash>);
|
||||||
|
|
||||||
// function used as objects in gXXX sets & maps
|
// function used as objects haser in fcl-stl
|
||||||
TObjectHash = class
|
TObjectHash = class
|
||||||
class function hash(key: TObject; maxBucketsPow2: longint): longint;
|
class function hash(key: TObject; maxBucketsPow2: longint): longint;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
generic TObjectHashSet<TValue> = class(specialize THashSet<TValue, TObjectHash>);
|
// HashSet for any object
|
||||||
|
generic TObjectHashSet<TValue: TObject> = class(specialize THashSet<TValue, TObjectHash>);
|
||||||
|
|
||||||
|
// Used instead of TStringList when the usage would mostly be ".IndexOf"
|
||||||
|
TStringHashSet = class(specialize THashSet<string, TStringHash>);
|
||||||
|
|
||||||
// aliased to get a custom prop inspector
|
// aliased to get a custom prop inspector
|
||||||
TCEPathname = type string;
|
TCEPathname = type string;
|
||||||
|
@ -322,7 +326,7 @@ begin
|
||||||
{$IFDEF CPU32}
|
{$IFDEF CPU32}
|
||||||
Result := longint(Pointer(key)) and (maxBucketsPow2 -1);
|
Result := longint(Pointer(key)) and (maxBucketsPow2 -1);
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
Result := (longInt(Pointer(key)) xor PlongInt(PInteger(&key) + 4)^) and (maxBucketsPow2 -1);
|
Result := longInt(Pointer(key)){ xor PlongInt(PInteger(&key) + 4)^)} and (maxBucketsPow2 -1);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
{$POP}
|
{$POP}
|
||||||
end;
|
end;
|
||||||
|
|
|
@ -27,7 +27,7 @@ type
|
||||||
private
|
private
|
||||||
fTempLines: TStringList;
|
fTempLines: TStringList;
|
||||||
fInputSource: string;
|
fInputSource: string;
|
||||||
fImportCache: TStringList;
|
fImportCache: TStringHashSet;
|
||||||
fPortNum: Word;
|
fPortNum: Word;
|
||||||
fServerWasRunning: boolean;
|
fServerWasRunning: boolean;
|
||||||
fClient, fServer: TProcess;
|
fClient, fServer: TProcess;
|
||||||
|
@ -114,7 +114,7 @@ begin
|
||||||
fServer.Parameters.Add('-p' + intToStr(port));
|
fServer.Parameters.Add('-p' + intToStr(port));
|
||||||
end;
|
end;
|
||||||
fTempLines := TStringList.Create;
|
fTempLines := TStringList.Create;
|
||||||
fImportCache := TStringList.Create;
|
fImportCache := TStringHashSet.Create;
|
||||||
|
|
||||||
if fServer.isNotNil then
|
if fServer.isNotNil then
|
||||||
begin
|
begin
|
||||||
|
@ -339,8 +339,9 @@ begin
|
||||||
if not fAvailable then exit;
|
if not fAvailable then exit;
|
||||||
if not fServerListening then exit;
|
if not fServerListening then exit;
|
||||||
//
|
//
|
||||||
if fImportCache.IndexOf(aFolder) <> -1 then exit;
|
if fImportCache.contains(aFolder) then
|
||||||
fImportCache.Add(aFolder);
|
exit;
|
||||||
|
fImportCache.insert(aFolder);
|
||||||
fClient.Parameters.Clear;
|
fClient.Parameters.Clear;
|
||||||
fClient.Parameters.Add('-I' + aFolder);
|
fClient.Parameters.Add('-I' + aFolder);
|
||||||
fClient.Execute;
|
fClient.Execute;
|
||||||
|
@ -357,9 +358,9 @@ begin
|
||||||
fClient.Parameters.Clear;
|
fClient.Parameters.Clear;
|
||||||
for imp in folders do
|
for imp in folders do
|
||||||
begin
|
begin
|
||||||
if fImportCache.IndexOf(imp) <> -1 then
|
if fImportCache.contains(imp) then
|
||||||
continue;
|
continue;
|
||||||
fImportCache.Add(imp);
|
fImportCache.insert(imp);
|
||||||
fClient.Parameters.Add('-I' + imp);
|
fClient.Parameters.Add('-I' + imp);
|
||||||
end;
|
end;
|
||||||
if fClient.Parameters.Count <> 0 then
|
if fClient.Parameters.Count <> 0 then
|
||||||
|
|
Loading…
Reference in New Issue