Skip to content

Commit c15c9c3

Browse files
committed
Use unsafe with a pointer instead of copy
1 parent 7ee651c commit c15c9c3

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/runtime/loader.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@ namespace Python.Runtime
1010
[Obsolete("Only to be used from within Python")]
1111
static class Loader
1212
{
13-
public static int Initialize(IntPtr data, int size)
13+
public unsafe static int Initialize(IntPtr data, int size)
1414
{
1515
IntPtr gs = IntPtr.Zero;
1616
try
1717
{
18-
var buf = new byte[size];
19-
Marshal.Copy(data, buf, 0, size);
20-
var dllPath = Encoding.UTF8.GetString(buf);
18+
var dllPath = Encoding.UTF8.GetString((byte*)data.ToPointer(), size);
2119

2220
if (!string.IsNullOrEmpty(dllPath))
2321
{

0 commit comments

Comments
 (0)