petris
4 years ago
No known key found for this signature in database
GPG Key ID: CEA06F305F42279F
2 changed files with
5 additions and
4 deletions
-
src/Avalonia.Base/Rendering/Composition/Transport/BatchStream.cs
-
src/Avalonia.X11/X11Structs.cs
|
|
|
@ -72,7 +72,7 @@ internal class BatchStreamWriter : IDisposable |
|
|
|
var size = Unsafe.SizeOf<T>(); |
|
|
|
if (_currentDataSegment.Data == IntPtr.Zero || _currentDataSegment.ElementCount + size > _memoryPool.BufferSize) |
|
|
|
NextDataSegment(); |
|
|
|
*(T*)((byte*)_currentDataSegment.Data + _currentDataSegment.ElementCount) = item; |
|
|
|
Unsafe.WriteUnaligned<T>((byte*)_currentDataSegment.Data + _currentDataSegment.ElementCount, item); |
|
|
|
_currentDataSegment.ElementCount += size; |
|
|
|
} |
|
|
|
|
|
|
|
@ -123,7 +123,7 @@ internal class BatchStreamReader : IDisposable |
|
|
|
if (_memoryOffset + size > _currentDataSegment.ElementCount) |
|
|
|
throw new InvalidOperationException("Attempted to read more memory then left in the current segment"); |
|
|
|
|
|
|
|
var rv = *(T*)((byte*)_currentDataSegment.Data + _memoryOffset); |
|
|
|
var rv = Unsafe.ReadUnaligned<T>((byte*)_currentDataSegment.Data + _memoryOffset); |
|
|
|
_memoryOffset += size; |
|
|
|
if (_memoryOffset == _currentDataSegment.ElementCount) |
|
|
|
{ |
|
|
|
@ -181,4 +181,4 @@ internal class BatchStreamReader : IDisposable |
|
|
|
while (_input.Objects.Count > 0) |
|
|
|
_objectPool.Return(_input.Objects.Dequeue().Data); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -32,6 +32,7 @@ using System.Collections; |
|
|
|
using System.Drawing; |
|
|
|
using System.Diagnostics; |
|
|
|
using System.Reflection; |
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
// ReSharper disable FieldCanBeMadeReadOnly.Global
|
|
|
|
// ReSharper disable IdentifierTypo
|
|
|
|
@ -545,7 +546,7 @@ namespace Avalonia.X11 { |
|
|
|
{ |
|
|
|
if (data == null) |
|
|
|
throw new InvalidOperationException(); |
|
|
|
return *(T*)data; |
|
|
|
return Unsafe.ReadUnaligned<T>(data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|