Avoid buffer allocations in CodeGenContext.GetCode(). Avoid stream allocations in PTC.PtcInfo.
Refactoring/nits.
This commit is contained in:
parent
b767d1a6b0
commit
f44271a617
6 changed files with 78 additions and 90 deletions
|
@ -302,13 +302,11 @@ namespace ARMeilleure.CodeGen.X86
|
|||
{
|
||||
Assembler assembler = new Assembler(codeStream, _ptcInfo);
|
||||
|
||||
Span<byte> buffer;
|
||||
|
||||
for (int index = 0; index < _jumps.Count; index++)
|
||||
{
|
||||
Jump jump = _jumps[index];
|
||||
|
||||
buffer = new byte[jump.JumpPosition - _stream.Position];
|
||||
Span<byte> buffer = new byte[jump.JumpPosition - _stream.Position];
|
||||
|
||||
_stream.Read(buffer);
|
||||
_stream.Seek(_ptcDisabled ? ReservedBytesForJump : jump.InstSize, SeekOrigin.Current);
|
||||
|
@ -325,13 +323,7 @@ namespace ARMeilleure.CodeGen.X86
|
|||
}
|
||||
}
|
||||
|
||||
buffer = new byte[_stream.Length - _stream.Position];
|
||||
|
||||
_stream.Read(buffer);
|
||||
|
||||
codeStream.Write(buffer);
|
||||
|
||||
_ptcInfo?.WriteCode(codeStream);
|
||||
_stream.CopyTo(codeStream);
|
||||
|
||||
return codeStream.ToArray();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue