mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-20 11:59:08 +02:00
GdbmiDebugger: small speed improvement if a user has huge amounts of watches
git-svn-id: trunk@44876 -
This commit is contained in:
parent
9be8a417f1
commit
809367783d
@ -291,9 +291,12 @@ type
|
|||||||
property Request: TGDBPTypeRequest read FRequest;
|
property Request: TGDBPTypeRequest read FRequest;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
const
|
||||||
|
TGDBPTypeReqCacheListCount = 64; // minimum 8
|
||||||
|
type
|
||||||
TGDBPTypeRequestCache = class
|
TGDBPTypeRequestCache = class
|
||||||
private
|
private
|
||||||
FList: TFPList;
|
FLists: Array[0..TGDBPTypeReqCacheListCount - 1] of TFPList;
|
||||||
function GetRequest(Index: Integer): TGDBPTypeRequest;
|
function GetRequest(Index: Integer): TGDBPTypeRequest;
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
@ -1974,26 +1977,32 @@ end;
|
|||||||
|
|
||||||
function TGDBPTypeRequestCache.GetRequest(Index: Integer): TGDBPTypeRequest;
|
function TGDBPTypeRequestCache.GetRequest(Index: Integer): TGDBPTypeRequest;
|
||||||
begin
|
begin
|
||||||
Result := TGDBPTypeRequestCacheEntry(FList[Index]).FRequest;
|
Result := TGDBPTypeRequestCacheEntry(FLists[Index mod TGDBPTypeReqCacheListCount][Index div TGDBPTypeReqCacheListCount]).FRequest;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TGDBPTypeRequestCache.Create;
|
constructor TGDBPTypeRequestCache.Create;
|
||||||
begin
|
begin
|
||||||
FList := TFPList.Create;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TGDBPTypeRequestCache.Destroy;
|
destructor TGDBPTypeRequestCache.Destroy;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
Clear;
|
Clear;
|
||||||
inherited Destroy;
|
inherited Destroy;
|
||||||
FreeAndNil(FList);
|
for i := 0 to high(FLists) do
|
||||||
|
FreeAndNil(FLists[i]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGDBPTypeRequestCache.Clear;
|
procedure TGDBPTypeRequestCache.Clear;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
while FList.Count > 0 do begin
|
for i := 0 to high(FLists) do
|
||||||
TGDBPTypeRequestCacheEntry(FList[0]).Free;
|
if FLists[i] <> nil then
|
||||||
FList.Delete(0);
|
while FLists[i].Count > 0 do begin
|
||||||
|
TGDBPTypeRequestCacheEntry(FLists[i][0]).Free;
|
||||||
|
FLists[i].Delete(0);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2002,16 +2011,27 @@ function TGDBPTypeRequestCache.IndexOf(AThreadId, AStackFrame: Integer;
|
|||||||
var
|
var
|
||||||
e: TGDBPTypeRequestCacheEntry;
|
e: TGDBPTypeRequestCacheEntry;
|
||||||
s: String;
|
s: String;
|
||||||
|
HashVal: Integer;
|
||||||
begin
|
begin
|
||||||
Result := FList.Count - 1;
|
|
||||||
s := UpperCase(ARequest.Request);
|
s := UpperCase(ARequest.Request);
|
||||||
|
// There are usually a couple of dozen entry total. Even if most are the same len the search will be quick
|
||||||
|
// Including stackframe, means nested procedures go in different lists.
|
||||||
|
HashVal := Length(s) mod (TGDBPTypeReqCacheListCount div 8) * 8
|
||||||
|
+ AStackFrame mod 4 * 2
|
||||||
|
+ ord(ARequest.ReqType);
|
||||||
|
Result := -1;
|
||||||
|
if FLists[HashVal] = nil then
|
||||||
|
exit;
|
||||||
|
Result := FLists[HashVal].Count - 1;
|
||||||
while Result >= 0 do begin
|
while Result >= 0 do begin
|
||||||
e := TGDBPTypeRequestCacheEntry(FList[Result]);
|
e := TGDBPTypeRequestCacheEntry(FLists[HashVal][Result]);
|
||||||
if (e.ThreadId = AThreadId) and (e.StackFrame = AStackFrame) and
|
if (e.ThreadId = AThreadId) and (e.StackFrame = AStackFrame) and
|
||||||
(e.Request.Request = s) and
|
(e.Request.Request = s) and
|
||||||
(e.Request.ReqType = ARequest.ReqType)
|
(e.Request.ReqType = ARequest.ReqType)
|
||||||
then
|
then begin
|
||||||
|
Result := Result * TGDBPTypeReqCacheListCount + HashVal;
|
||||||
exit;
|
exit;
|
||||||
|
end;
|
||||||
dec(Result);
|
dec(Result);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2020,6 +2040,7 @@ procedure TGDBPTypeRequestCache.Add(AThreadId, AStackFrame: Integer;
|
|||||||
ARequest: TGDBPTypeRequest);
|
ARequest: TGDBPTypeRequest);
|
||||||
var
|
var
|
||||||
e: TGDBPTypeRequestCacheEntry;
|
e: TGDBPTypeRequestCacheEntry;
|
||||||
|
HashVal: Integer;
|
||||||
begin
|
begin
|
||||||
e := TGDBPTypeRequestCacheEntry.Create;
|
e := TGDBPTypeRequestCacheEntry.Create;
|
||||||
e.FThreadId := AThreadId;
|
e.FThreadId := AThreadId;
|
||||||
@ -2027,7 +2048,12 @@ begin
|
|||||||
e.FRequest := ARequest;
|
e.FRequest := ARequest;
|
||||||
e.FRequest.Request := UpperCase(e.FRequest.Request);
|
e.FRequest.Request := UpperCase(e.FRequest.Request);
|
||||||
e.FRequest.Next := nil;
|
e.FRequest.Next := nil;
|
||||||
FList.Add(e);
|
HashVal := Length(ARequest.Request) mod (TGDBPTypeReqCacheListCount div 8) * 8
|
||||||
|
+ AStackFrame mod 4 * 2
|
||||||
|
+ ord(ARequest.ReqType);
|
||||||
|
if FLists[HashVal] = nil then
|
||||||
|
FLists[HashVal] := TFPList.Create;
|
||||||
|
FLists[HashVal].Add(e);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TGDBPType }
|
{ TGDBPType }
|
||||||
|
Loading…
Reference in New Issue
Block a user