Einzelnen Beitrag anzeigen

Benutzerbild von Union
Union
Online

Registriert seit: 18. Mär 2004
Ort: Luxembourg
3.492 Beiträge
 
Delphi 7 Enterprise
 
#6

AW: Look for specified sequence in stream

  Alt 19. Sep 2013, 15:57
You should eliminate object access there by copying the values to local variables.
Delphi-Quellcode:
var
  Position, Size : int64;
  MemoryPtr : Pointer;
  PatternLen : int64;
  MaxPosition : int64;
begin
  ...
  Memory := TMemoryStream.Create;
  try
    Memory.CopyFrom(AStream, 0);
    Memory.Position := 0;
    
    // Work only with variables to eliminate Object access
    MemoryPtr := Memory.Memory;
    Position := Memory.Position;
    Size := Memory.Size;
    PatternLen := Length(APattern);

    // No calculation of end condition
    MaxPosition := Size - PatternLen + 1;

    while Position < MaxPosition do
    begin
      Offset := Position;
      Buffer := Byte(Pointer(Longint(MemoryPtr) + Offset)^);

      // ????? :(
    end;
Ibi fas ubi proxima merces
sudo /Developer/Library/uninstall-devtools --mode=all
  Mit Zitat antworten Zitat