mirror of
https://github.com/crskycode/GARbro.git
synced 2024-12-24 03:44:13 +08:00
(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:
parent
cf0d6e9e3c
commit
b442bd5afb
@ -429,6 +429,27 @@ namespace GameRes
|
||||
{
|
||||
size = Math.Min (size, Reserve (offset, size));
|
||||
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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user