mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
small optimizations
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@3685 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
@@ -31,8 +31,8 @@ __declspec(naked) int __cdecl ph_equal_string(wchar_t *s1, wchar_t *s2, size_t l
|
||||
push esi
|
||||
push edi
|
||||
|
||||
mov eax, [esp+0xc+0x8] // len
|
||||
mov ecx, [esp+0xc+0x8] // len
|
||||
mov eax, [esp+0xc+0x8] // len
|
||||
|
||||
and ecx, -2 // round down to even number
|
||||
mov esi, [esp+0xc+0x0] // s1
|
||||
|
||||
@@ -1333,6 +1333,7 @@ PPH_STRING PhFormatSize(
|
||||
WCHAR numberString[512]; // perf hack
|
||||
PPH_STRING formattedString;
|
||||
PPH_STRING outputString;
|
||||
ULONG length;
|
||||
|
||||
swprintf_s(numberString, sizeof(numberString) / 2, L"%.2f", s);
|
||||
formattedString = PhFormatDecimal(numberString, 2, TRUE);
|
||||
@@ -1342,19 +1343,22 @@ PPH_STRING PhFormatSize(
|
||||
return PhFormatString(L"%.2g %s", s, PhSizeUnitNames[i]);
|
||||
}
|
||||
|
||||
length = formattedString->Length / 2;
|
||||
|
||||
if (
|
||||
PhEndsWithString2(formattedString, L"00", FALSE) &&
|
||||
formattedString->Length >= 6
|
||||
length >= 3 &&
|
||||
formattedString->Buffer[length - 1] == '0' &&
|
||||
formattedString->Buffer[length - 2] == '0'
|
||||
)
|
||||
{
|
||||
// Remove the last three characters by making sure
|
||||
// PhConcatStrings doesn't include them.
|
||||
formattedString->Buffer[formattedString->Length / 2 - 3] = 0;
|
||||
formattedString->Buffer[length - 3] = 0;
|
||||
}
|
||||
else if (PhEndsWithString2(formattedString, L"0", FALSE))
|
||||
else if (length >= 1 && formattedString->Buffer[length - 1] == '0')
|
||||
{
|
||||
// Remove the last character.
|
||||
formattedString->Buffer[formattedString->Length / 2 - 1] = 0;
|
||||
formattedString->Buffer[length - 1] = 0;
|
||||
}
|
||||
|
||||
outputString = PhConcatStrings(3, formattedString->Buffer, L" ", PhSizeUnitNames[i]);
|
||||
|
||||
Reference in New Issue
Block a user