Skip to content

Commit 03586d1

Browse files
author
Arnaud Bouchez
committed
core: new AppendShortTwoChars() overload
1 parent aa5fba3 commit 03586d1

6 files changed

+26
-13
lines changed

src/core/mormot.core.base.pas

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,12 @@ procedure AppendShortChar(chr: AnsiChar; dest: PAnsiChar);
972972

973973
/// simple concatenation of two characters into a @shorstring
974974
// - dest is @shortstring and not shortstring to circumvent a Delphi inlining bug
975-
procedure AppendShortTwoChars(twochars, dest: PAnsiChar);
975+
procedure AppendShortTwoChars(twochars, dest: PAnsiChar); overload;
976+
{$ifdef HASINLINE} inline; {$endif}
977+
978+
/// simple concatenation of two characters (as 16-bit integer) into a @shorstring
979+
// - dest is @shortstring and not shortstring to circumvent a Delphi inlining bug
980+
procedure AppendShortTwoChars(twochars: cardinal; dest: PAnsiChar); overload;
976981
{$ifdef HASINLINE} inline; {$endif}
977982

978983
/// simple concatenation of a #0 ending text into a @shorstring
@@ -5215,6 +5220,12 @@ procedure AppendShortTwoChars(twochars, dest: PAnsiChar);
52155220
inc(dest[0], 2);
52165221
end;
52175222

5223+
procedure AppendShortTwoChars(twochars: cardinal; dest: PAnsiChar);
5224+
begin
5225+
PWord(dest + ord(dest[0]) + 1)^ := twochars;
5226+
inc(dest[0], 2);
5227+
end;
5228+
52185229
procedure AppendShortBuffer(buf: PAnsiChar; len: PtrInt; dest: PAnsiChar);
52195230
begin
52205231
if len + ord(dest[0]) > 255 then

src/core/mormot.core.os.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8079,7 +8079,7 @@ function GetMemoryInfoText: TShort31;
80798079
AppendShortKB(info.memtotal - info.memfree, info.memtotal, result);
80808080
AppendShortChar('(', @result);
80818081
AppendShortCardinal(info.percent, result);
8082-
AppendShortTwoChars('%)', @result);
8082+
AppendShortTwoChars(ord('%') + ord(')') shl 8, @result);
80838083
end;
80848084

80858085
function GetDiskAvailable(aDriveFolderOrFile: TFileName): QWord;

src/core/mormot.core.os.security.pas

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3192,7 +3192,7 @@ procedure SddlAppendMask(var s: ShortString; mask: TSecAccessMask);
31923192
AppendShortTwoChars(@SAR_SDDL[TSecAccessRight(i)][1], @s)
31933193
else if mask - samWithSddl <> [] then
31943194
begin
3195-
AppendShortTwoChars('0x', @s); // we don't have all tokens it needs
3195+
AppendShortTwoChars('0x', @s); // we don't have all needed tokens
31963196
AppendShortIntHex(cardinal(mask), s); // store as @x##### hexadecimal
31973197
end
31983198
else
@@ -4792,9 +4792,9 @@ procedure TSecurityDescriptor.AclToText(var sddl: TSynTempBuffer;
47924792
if SCOPE_P[scope] in Flags then
47934793
AppendShortChar('P', @tmp);
47944794
if SCOPE_AR[scope] in Flags then
4795-
AppendShortTwoChars('AR', @tmp);
4795+
AppendShortTwoChars(ord('A') + ord('R') shl 8, @tmp);
47964796
if SCOPE_AI[scope] in Flags then
4797-
AppendShortTwoChars('AI', @tmp);
4797+
AppendShortTwoChars(ord('A') + ord('I') shl 8, @tmp);
47984798
acl := @Dacl;
47994799
if scope = sasSacl then
48004800
acl := @Sacl;
@@ -4878,12 +4878,12 @@ procedure TSecurityDescriptor.AppendAsText(var sddl: TSynTempBuffer;
48784878
tmp[0] := #0;
48794879
if Owner <> '' then
48804880
begin
4881-
tmp := 'O:';
4881+
AppendShortTwoChars(ord('O') + ord(':') shl 8, @tmp);
48824882
SddlAppendSid(tmp, pointer(Owner), dom);
48834883
end;
48844884
if Group <> '' then
48854885
begin
4886-
AppendShortTwoChars('G:', @tmp);
4886+
AppendShortTwoChars(ord('G') + ord(':') shl 8, @tmp);
48874887
SddlAppendSid(tmp, pointer(Group), dom);
48884888
end;
48894889
sddl.AddShort(tmp);

src/core/mormot.core.perf.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2610,7 +2610,7 @@ function TSynMonitorOneSize.GetAsText: TShort16;
26102610
function TSynMonitorThroughput.GetAsText: TShort16;
26112611
begin
26122612
AppendKB(fBytesPerSec, result, not fTextNoSpace);
2613-
AppendShortTwoChars('/s', @result);
2613+
AppendShortTwoChars(ord('/') + ord('s') shl 8, @result);
26142614
end;
26152615

26162616

src/core/mormot.core.text.pas

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9685,10 +9685,12 @@ procedure _TimeToString(value: cardinal; const u: ShortString;
96859685

96869686
procedure MicroSecToString(Micro: QWord; out result: TShort16);
96879687
begin
9688-
if Int64(Micro) <= 0 then
9689-
PCardinal(@result)^ := 3 + ord('0') shl 8 + ord('u') shl 16 + ord('s') shl 24
9690-
else if Micro < 1000 then
9691-
FormatShort16('%us', [Micro], result)
9688+
result[0] := #0;
9689+
if Micro < 1000 then
9690+
begin
9691+
AppendShortCardinal(Micro, result);
9692+
AppendShortTwoChars(ord('u') + ord('s') shl 8, @result);
9693+
end
96929694
else if Micro < 1000000 then
96939695
By100ToTwoDigitString(
96949696
{$ifdef CPU32} PCardinal(@Micro)^ {$else} Micro {$endif} div 10, 'ms', result)

src/mormot.commit.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
'2.3.10634'
1+
'2.3.10635'

0 commit comments

Comments
 (0)