const str optimization
This commit is contained in:
@@ -3,7 +3,9 @@ program fpcunitproject1;
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
Classes, consoletestrunner, TestCase1;
|
||||
Classes,
|
||||
consoletestrunner,
|
||||
TestCase1;
|
||||
|
||||
type
|
||||
|
||||
@@ -11,7 +13,7 @@ type
|
||||
|
||||
TMyTestRunner = class(TTestRunner)
|
||||
protected
|
||||
// override the protected methods of TTestRunner to customize its behavior
|
||||
// override the protected methods of TTestRunner to customize its behavior
|
||||
end;
|
||||
|
||||
var
|
||||
|
||||
@@ -9,15 +9,15 @@
|
||||
<Filename Value="fpcunitproject1.lpr"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<EditorIndex Value="-1"/>
|
||||
<CursorPos Y="23"/>
|
||||
<UsageCount Value="194"/>
|
||||
<UsageCount Value="195"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="TestCase1"/>
|
||||
<CursorPos X="116" Y="32"/>
|
||||
<UsageCount Value="194"/>
|
||||
<TopLine Value="22"/>
|
||||
<CursorPos X="5" Y="35"/>
|
||||
<UsageCount Value="195"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
@@ -25,9 +25,8 @@
|
||||
<IsPartOfProject Value="True"/>
|
||||
<IsVisibleTab Value="True"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<TopLine Value="362"/>
|
||||
<CursorPos X="34" Y="376"/>
|
||||
<UsageCount Value="194"/>
|
||||
<CursorPos X="69" Y="22"/>
|
||||
<UsageCount Value="195"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
@@ -38,22 +37,22 @@
|
||||
<UsageCount Value="4"/>
|
||||
</Unit3>
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<JumpHistory Count="29" HistoryIndex="28">
|
||||
<Position1>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="34" Column="38" TopLine="10"/>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="48" Column="58" TopLine="34"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="29" TopLine="4"/>
|
||||
<Caret Line="17" Column="26" TopLine="5"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="41" Column="51" TopLine="28"/>
|
||||
<Caret Line="50" Column="58" TopLine="35"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="48" Column="53" TopLine="9"/>
|
||||
<Caret Line="48" Column="63" TopLine="24"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
@@ -61,104 +60,98 @@
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="48" Column="58" TopLine="34"/>
|
||||
<Caret Line="48" Column="59" TopLine="33"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="17" Column="26" TopLine="5"/>
|
||||
<Caret Line="21" TopLine="6"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="50" Column="58" TopLine="35"/>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="25" Column="27" TopLine="13"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="48" Column="63" TopLine="24"/>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="32" Column="57" TopLine="11"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="19" Column="11" TopLine="5"/>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="328" Column="7" TopLine="305"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="48" Column="59" TopLine="33"/>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="317" Column="25" TopLine="315"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="21" TopLine="6"/>
|
||||
<Caret Line="28" Column="50" TopLine="15"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="25" Column="27" TopLine="13"/>
|
||||
<Caret Line="21" Column="7" TopLine="7"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="32" Column="57" TopLine="11"/>
|
||||
<Caret Line="64" Column="35" TopLine="50"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="328" Column="7" TopLine="305"/>
|
||||
<Caret Line="28" Column="30" TopLine="10"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="317" Column="25" TopLine="315"/>
|
||||
<Caret Line="134" Column="47" TopLine="134"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
<Caret Line="28" Column="50" TopLine="15"/>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="179" Column="32" TopLine="165"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="21" Column="7" TopLine="7"/>
|
||||
<Caret Line="184" Column="37" TopLine="170"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="64" Column="35" TopLine="50"/>
|
||||
<Caret Line="257" Column="33" TopLine="243"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="28" Column="30" TopLine="10"/>
|
||||
<Caret Line="297" Column="33" TopLine="283"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="134" Column="47" TopLine="134"/>
|
||||
<Caret Line="310" Column="40" TopLine="296"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="179" Column="32" TopLine="165"/>
|
||||
<Caret Line="312" Column="6" TopLine="301"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="184" Column="37" TopLine="170"/>
|
||||
<Caret Line="324" Column="21" TopLine="301"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="257" Column="33" TopLine="243"/>
|
||||
<Caret Line="344" Column="35" TopLine="330"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="297" Column="33" TopLine="283"/>
|
||||
<Caret Line="360" Column="37" TopLine="346"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="310" Column="40" TopLine="296"/>
|
||||
<Caret Line="368" Column="34" TopLine="362"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="312" Column="6" TopLine="301"/>
|
||||
<Filename Value="testcase1.pas"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="324" Column="21" TopLine="301"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="344" Column="35" TopLine="330"/>
|
||||
<Caret Line="8" Column="47"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="..\AG.Logs.pas"/>
|
||||
<Caret Line="360" Column="37" TopLine="346"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectSession>
|
||||
<Debugging>
|
||||
|
||||
@@ -5,50 +5,53 @@ unit TestCase1;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, fpcunit, testutils, testregistry, AG.Logs{$IFDEF MSWINDOWS},Windows{$ENDIF};
|
||||
Classes, SysUtils, fpcunit, testutils, testregistry,
|
||||
AG.Logs{$IFDEF MSWINDOWS}, Windows{$ENDIF};
|
||||
|
||||
type
|
||||
|
||||
TTestCase1= class(TTestCase)
|
||||
TTestCase1 = class(TTestCase)
|
||||
published
|
||||
procedure TestHookUp;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
procedure Test(s:string);
|
||||
procedure Test(s: string);
|
||||
begin
|
||||
Write(s);
|
||||
end;
|
||||
|
||||
procedure TTestCase1.TestHookUp;
|
||||
var
|
||||
MultiLog:TAGLog;
|
||||
Stream:TStream;
|
||||
s:TBytes;
|
||||
MultiLog: TAGLog;
|
||||
Stream: TStream;
|
||||
s: TBytes;
|
||||
begin
|
||||
MultiLog:=TAGMultiLog.Create(nil);
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGNullLog.Create());
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGDiskLog.Create('test.log'));
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGRamLog.Create());
|
||||
{$IFDEF MSWINDOWS}(MultiLog as TAGMultiLog).Logs.Add(TAGCommandLineLog.Create(GetStdHandle(STD_OUTPUT_HANDLE))){$ENDIF};
|
||||
Stream:=nil;
|
||||
try
|
||||
Stream:=TFileStream.Create('test2.log',fmOpenRead+fmShareDenyNone);
|
||||
SetLength(s,Stream.Size);
|
||||
Stream.Read(s[0],Stream.Size);
|
||||
except
|
||||
SetLength(s,0);
|
||||
end;
|
||||
FreeAndNil(Stream);
|
||||
Stream:=TFileStream.Create('test2.log',fmCreate+fmOpenReadWrite+fmShareDenyWrite);
|
||||
Stream.Write(s[0],Length(s));
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGStreamLog.Create(Stream));
|
||||
SetLength(s,0);
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGCallBackLog.Create(@Test));
|
||||
MultiLog.Write('Str Test');
|
||||
MultiLog.Write('Str+Object Test',self);
|
||||
FreeAndNil(MultiLog);
|
||||
MultiLog := TAGMultiLog.Create(nil);
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGNullLog.Create());
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGDiskLog.Create('test.log'));
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGRamLog.Create());
|
||||
{$IFDEF MSWINDOWS}
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGCommandLineLog.Create(GetStdHandle(STD_OUTPUT_HANDLE)));
|
||||
{$ENDIF}
|
||||
Stream := nil;
|
||||
try
|
||||
Stream := TFileStream.Create('test2.log', fmOpenRead + fmShareDenyNone);
|
||||
SetLength(s, Stream.Size);
|
||||
Stream.Read(s[0], Stream.Size);
|
||||
except
|
||||
SetLength(s, 0);
|
||||
end;
|
||||
FreeAndNil(Stream);
|
||||
Stream := TFileStream.Create('test2.log', fmCreate + fmOpenReadWrite +
|
||||
fmShareDenyWrite);
|
||||
Stream.Write(s[0], Length(s));
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGStreamLog.Create(Stream));
|
||||
SetLength(s, 0);
|
||||
(MultiLog as TAGMultiLog).Logs.Add(TAGCallBackLog.Create(@Test));
|
||||
MultiLog.Write('Str Test');
|
||||
MultiLog.Write('Str+Object Test', self);
|
||||
FreeAndNil(MultiLog);
|
||||
end;
|
||||
|
||||
|
||||
@@ -57,4 +60,3 @@ initialization
|
||||
|
||||
RegisterTest(TTestCase1);
|
||||
end.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user