mirror of
https://github.com/opensim/opensim.git
synced 2026-08-13 05:05:43 +08:00
cosmetics
This commit is contained in:
@@ -324,10 +324,8 @@ namespace OpenSim.Framework.Console
|
||||
m_cursorYPosition = SetCursorZeroLeft(m_cursorYPosition);
|
||||
|
||||
int count = m_commandLine.Length + prompt.Length;
|
||||
char[] spaces = new char[count];
|
||||
for(int i = 0; i < spaces.Length; i++)
|
||||
spaces[i] = ' ';
|
||||
System.Console.Write(spaces);
|
||||
if(count > 0)
|
||||
System.Console.Write(new string(' ', count));
|
||||
|
||||
m_cursorYPosition = SetCursorZeroLeft(m_cursorYPosition);
|
||||
}
|
||||
@@ -444,11 +442,12 @@ namespace OpenSim.Framework.Console
|
||||
m_cursorYPosition = SetCursorZeroLeft(m_cursorYPosition);
|
||||
|
||||
int count = m_commandLine.Length + prompt.Length - text.Length;
|
||||
|
||||
WriteLocalText(text, level);
|
||||
for (int i = 0; i < count; ++i)
|
||||
System.Console.Write(" ");
|
||||
System.Console.WriteLine();
|
||||
if(count > 0)
|
||||
System.Console.WriteLine(new string(' ', count));
|
||||
else
|
||||
System.Console.WriteLine();
|
||||
|
||||
m_cursorYPosition = System.Console.CursorTop;
|
||||
Show();
|
||||
}
|
||||
|
||||
@@ -1230,31 +1230,66 @@ namespace OpenSim.Framework
|
||||
return (char)(b > 9 ? b + 0x37 : b + '0');
|
||||
}
|
||||
|
||||
public static string bytesToHexString(Span<byte> bytes, bool lowerCaps)
|
||||
public static unsafe string bytesToHexString(byte[] bytes, bool lowerCaps)
|
||||
{
|
||||
if (bytes == null || bytes.Length == 0)
|
||||
return string.Empty;
|
||||
|
||||
Span<char> chars = stackalloc char[2 * bytes.Length];
|
||||
if (lowerCaps)
|
||||
return string.Create(2 * bytes.Length, bytes, (chars, bytes) =>
|
||||
{
|
||||
fixed (char* dstb = chars)
|
||||
fixed (byte* srcb = bytes)
|
||||
{
|
||||
char* dst = dstb;
|
||||
if (lowerCaps)
|
||||
{
|
||||
for (int i = 0; i < bytes.Length; ++i)
|
||||
{
|
||||
byte b = srcb[i];
|
||||
*dst++ = HighNibbleToHexByteCharLowcaps(b);
|
||||
*dst++ = LowNibbleToHexByteCharLowcaps(b);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < bytes.Length; ++i)
|
||||
{
|
||||
byte b = srcb[i];
|
||||
*dst++ = HighNibbleToHexByteCharLowcaps(b);
|
||||
*dst++ = LowNibbleToHexByteCharLowcaps(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static unsafe string bytesToLowcaseHexString(byte[] bytes)
|
||||
{
|
||||
if (bytes == null || bytes.Length == 0)
|
||||
return string.Empty;
|
||||
|
||||
return string.Create(2 * bytes.Length, bytes, (chars, bytes) =>
|
||||
{
|
||||
fixed (char* dstb = chars)
|
||||
fixed (byte* srcb = bytes)
|
||||
{
|
||||
char* dst = dstb;
|
||||
for (int i = 0; i < bytes.Length; ++i)
|
||||
{
|
||||
byte b = srcb[i];
|
||||
*dst++ = HighNibbleToHexByteCharLowcaps(b);
|
||||
*dst++ = LowNibbleToHexByteCharLowcaps(b);
|
||||
}
|
||||
}
|
||||
/*
|
||||
for (int i = 0, j = 0; i < bytes.Length; ++i)
|
||||
{
|
||||
byte b = bytes[i];
|
||||
chars[j++] = HighNibbleToHexByteCharLowcaps(b);
|
||||
chars[j++] = LowNibbleToHexByteCharLowcaps(b);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0, j = 0; i < bytes.Length; ++i)
|
||||
{
|
||||
byte b = bytes[i];
|
||||
chars[j++] = HighNibbleToHexByteCharHighcaps(b);
|
||||
chars[j++] = LowNibbleToHexByteCharHighcaps(b);
|
||||
}
|
||||
}
|
||||
return new string(chars);
|
||||
*/
|
||||
});
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
Reference in New Issue
Block a user