(ArcView.ReadString): added commented out unsafe implementation.

unsafe variant doesn't allocate temporary buffer for name, but requires
.Net framework version 4.6 or later.
This commit is contained in:
morkt 2015-12-08 20:56:10 +04:00
parent cf0d6e9e3c
commit b442bd5afb

View File

@ -429,6 +429,27 @@ namespace GameRes
{ {
size = Math.Min (size, Reserve (offset, size)); size = Math.Min (size, Reserve (offset, size));
return m_view.ReadString (offset-m_offset, size, enc); return m_view.ReadString (offset-m_offset, size, enc);
/* unsafe implementation requires .Net v4.6
if (0 == size)
return string.Empty;
unsafe
{
byte* s = m_view.GetPointer (m_offset) + (offset - m_offset);
try
{
uint string_length = 0;
while (string_length < size && 0 != s[string_length])
{
++string_length;
}
return enc.GetString (s, (int)string_length); // .Net v4.6+ only
}
finally
{
m_view.SafeMemoryMappedViewHandle.ReleasePointer();
}
}
*/
} }
public string ReadString (long offset, uint size) public string ReadString (long offset, uint size)