From 8bd7ffa74cf458e44dc5ea679fced7c4ea5c1e42 Mon Sep 17 00:00:00 2001 From: Herwin Bozet Date: Thu, 5 Nov 2026 07:32:34 +0100 Subject: [PATCH] Implemented FastNumericPeekPoke --- .gitmodules | 3 +++ Claude.MD | 1 + Includes/PB-FastNumericPeekPoke | 1 + Includes/_Binary.pbi | 24 ++++++++--------- Includes/_Commons.pbi | 6 +++++ Includes/_Extensions.pbi | 6 ++--- Includes/_Iterators.pbi | 40 ++++++++++++++-------------- Includes/_Literals.pbi | 8 +++--- Includes/_Primitives.pbi | 46 ++++++++++++++++----------------- Includes/_Utils.pbi | 2 +- 10 files changed, 74 insertions(+), 63 deletions(-) create mode 160000 Includes/PB-FastNumericPeekPoke diff --git a/.gitmodules b/.gitmodules index adb4077..03b6d42 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "Includes/PB-Endianness"] path = Includes/PB-Endianness url = https://github.com/aziascreations/PB-Endianness.git +[submodule "Includes/PB-FastNumericPeekPoke"] + path = Includes/PB-FastNumericPeekPoke + url = https://github.com/aziascreations/PB-FastNumericPeekPoke.git diff --git a/Claude.MD b/Claude.MD index 09b9f39..aed99af 100644 --- a/Claude.MD +++ b/Claude.MD @@ -417,6 +417,7 @@ or subtract each top-level field's `MsgPackGetFieldFullSize` from the buffer's s * `Includes/MessagePack.pbi` - Main file, only includes the others. * `Includes/_*.pbi` - One file per family. (Allocators, Literals, Primitives, Strings, ...) * `Includes/PB-Endianness/` - Git submodule, don't edit it from here. +* `Includes/PB-FastNumericPeekPoke/` - Git submodule, don't edit it from here. Use `FastPeekX()`/`FastPokeX()` instead of the numeric `PeekX()`/`PokeX()`. * `UnitTests/` - One folder per family, numbered like the includes' order. * `Examples/` - One folder per example, with a `.pb` of the same name. * `PerfTests/` - Benchmarks, one folder per workload, each with a `RunPerfTests.ps1`. diff --git a/Includes/PB-FastNumericPeekPoke b/Includes/PB-FastNumericPeekPoke new file mode 160000 index 0000000..4b71366 --- /dev/null +++ b/Includes/PB-FastNumericPeekPoke @@ -0,0 +1 @@ +Subproject commit 4b71366a45687c8b5c68cd7ff9ea1622903397a5 diff --git a/Includes/_Binary.pbi b/Includes/_Binary.pbi index 21a8e8a..8b89454 100644 --- a/Includes/_Binary.pbi +++ b/Includes/_Binary.pbi @@ -107,16 +107,16 @@ Procedure.MsgPack_ErrorCode _MsgPackWriteSizedFieldHeader(*MsgPackData.MsgPackDa Select SizeFieldByteLength Case 0 - PokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode | DataSize) + FastPokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode | DataSize) Case 1 - PokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode) - PokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1, DataSize) + FastPokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode) + FastPokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1, DataSize) Case 2 - PokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode) - PokeU(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1, EndianSwapU16(DataSize)) + FastPokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode) + FastPokeU(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1, EndianSwapU16(DataSize)) Case 4 - PokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode) - PokeL(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1, EndianSwapI32(DataSize)) + FastPokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode) + FastPokeL(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1, EndianSwapI32(DataSize)) EndSelect *MsgPackData\BufferOffset = *MsgPackData\BufferOffset + 1 + SizeFieldByteLength @@ -181,7 +181,7 @@ Procedure.MsgPack_ErrorCode _MsgPackReadSizedFieldHeader(*MsgPackData.MsgPackDat FormatCode = MsgPackGetFormatCode(*MsgPackData) If MsgPackFormatCodeToDataType(FormatCode) <> ExpectedDataType - Debug("Unexpected format code ! (" + RSet(Hex(PeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset)), 2, "0") + ")") + Debug("Unexpected format code ! (" + RSet(Hex(FastPeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset)), 2, "0") + ")") *MsgPackData\LastError = #MsgPack_Error_InvalidFormatCode ProcedureReturn #MsgPack_Error_InvalidFormatCode EndIf @@ -227,14 +227,14 @@ Procedure.MsgPack_ErrorCode _MsgPackReadSizedFieldHeader(*MsgPackData.MsgPackDat Case 0: ; FixExt sizes were already set above. If FormatCode = #MsgPack_FormatCode_FixStr - DataSize = PeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset) & %00011111 + DataSize = FastPeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset) & %00011111 EndIf Case 1: - DataSize = PeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1) + DataSize = FastPeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1) Case 2: - DataSize = EndianSwapU16(PeekU(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1)) + DataSize = EndianSwapU16(FastPeekU(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1)) Case 4: - DataSize = EndianSwapI32(PeekL(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1)) & $FFFFFFFF + DataSize = EndianSwapI32(FastPeekL(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1)) & $FFFFFFFF EndSelect If Not _MsgPackHasSpaceLeft(*MsgPackData, 1 + SizeFieldByteLength + ExtTypeByteLength + DataSize) diff --git a/Includes/_Commons.pbi b/Includes/_Commons.pbi index c0547c0..d51d562 100644 --- a/Includes/_Commons.pbi +++ b/Includes/_Commons.pbi @@ -34,6 +34,12 @@ CompilerIf Not Defined(_NibblePoker_Endianness_WasIncluded, #PB_Constant) And No XIncludeFile "./PB-Endianness/Includes/Endianness.pbi" CompilerEndIf +; Skipped if "FastNumericPeekPoke.pbi" was already included from another path, by the program or another include. +; Its procedures are only used on the C backend with "/OPTIMIZER", they alias the built-ins otherwise. +CompilerIf Not Defined(_NibblePoker_FastNumericPeekPoke_WasIncluded, #PB_Constant) + XIncludeFile "./PB-FastNumericPeekPoke/Includes/FastNumericPeekPoke.pbi" +CompilerEndIf + ; ------------------------------------------------------------------------------ diff --git a/Includes/_Extensions.pbi b/Includes/_Extensions.pbi index 92833b2..ff4c356 100644 --- a/Includes/_Extensions.pbi +++ b/Includes/_Extensions.pbi @@ -96,7 +96,7 @@ Procedure.MsgPack_ErrorCode _MsgPackWriteExtField(*MsgPackData.MsgPackData, Form ProcedureReturn ErrorCode EndIf - PokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode) + FastPokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode) *MsgPackData\BufferOffset = *MsgPackData\BufferOffset + 1 Else ErrorCode = _MsgPackWriteSizedFieldHeader(*MsgPackData, FormatCode, SizeFieldByteLength, DataSize, 1, *Data) @@ -105,7 +105,7 @@ Procedure.MsgPack_ErrorCode _MsgPackWriteExtField(*MsgPackData.MsgPackData, Form EndIf EndIf - PokeB(*MsgPackData\Buffer + *MsgPackData\BufferOffset, ExtType) + FastPokeB(*MsgPackData\Buffer + *MsgPackData\BufferOffset, ExtType) *MsgPackData\BufferOffset = *MsgPackData\BufferOffset + 1 If DataSize > 0 @@ -133,7 +133,7 @@ Procedure.b MsgPackGetExtensionType(*MsgPackData.MsgPackData) ProcedureReturn 0 EndIf - ProcedureReturn PeekB(*MsgPackData\Buffer + *MsgPackData\BufferOffset + HeaderSize - 1) + ProcedureReturn FastPeekB(*MsgPackData\Buffer + *MsgPackData\BufferOffset + HeaderSize - 1) EndProcedure diff --git a/Includes/_Iterators.pbi b/Includes/_Iterators.pbi index 85a158d..ceb04c1 100644 --- a/Includes/_Iterators.pbi +++ b/Includes/_Iterators.pbi @@ -46,7 +46,7 @@ XIncludeFile "./_Binary.pbi" ; `XXX` is the format code bits and `YYYYY` the value's dynamic size. ; Applies to: FixStr, FixArray, FixMap ; Remark: Doesn't apply to FixInt variants since those have their own function for extracting the value. -Macro _MsgPackGetFieldDynamicSize_Within(MsgPackData, Mask) : (PeekA(MsgPackData\Buffer + MsgPackData\BufferOffset) & Mask) : EndMacro +Macro _MsgPackGetFieldDynamicSize_Within(MsgPackData, Mask) : (FastPeekA(MsgPackData\Buffer + MsgPackData\BufferOffset) & Mask) : EndMacro ; Returns the field's dynamic size based on the byte right after the format code. ; Applies to: Str8, Bin8, Ext8 @@ -57,7 +57,7 @@ Procedure.q _MsgPackGetFieldDynamicSize_1After(*MsgPackData.MsgPackData) ProcedureReturn #MsgPack_InvalidSize EndIf - ProcedureReturn PeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1) + ProcedureReturn FastPeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1) EndProcedure ; Returns the field's dynamic size based on the 2 bytes right after the format code. @@ -69,7 +69,7 @@ Procedure.q _MsgPackGetFieldDynamicSize_2After(*MsgPackData.MsgPackData) ProcedureReturn #MsgPack_InvalidSize EndIf - ProcedureReturn EndianSwapU(PeekU(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1)) + ProcedureReturn EndianSwapU(FastPeekU(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1)) EndProcedure ; Returns the field's dynamic size based on the 4 bytes right after the format code. @@ -81,7 +81,7 @@ Procedure.q _MsgPackGetFieldDynamicSize_4After(*MsgPackData.MsgPackData) ProcedureReturn #MsgPack_InvalidSize EndIf - ProcedureReturn EndianSwapL(PeekL(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1)) & $FFFFFFFF + ProcedureReturn EndianSwapL(FastPeekL(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1)) & $FFFFFFFF EndProcedure ; Returns a given format code's spacing info based on itself and the data in the given MsgPack buffer. @@ -110,20 +110,20 @@ Procedure _MsgPackGetFieldSpacingInfo(*MsgPackData.MsgPackData, ExaminedDataType Select ExaminedDataType Case #MsgPack_FormatCode_FixStr: If *VariableSizeQ <> #Null - PokeQ(*VariableSizeQ, _MsgPackGetFieldDynamicSize_Within(*MsgPackData, %00011111)) + FastPokeQ(*VariableSizeQ, _MsgPackGetFieldDynamicSize_Within(*MsgPackData, %00011111)) EndIf If *ValueStartOffsetB <> #Null - PokeB(*ValueStartOffsetB, 1) + FastPokeB(*ValueStartOffsetB, 1) EndIf ProcedureReturn #True Case #MsgPack_FormatCode_FixArray, #MsgPack_FormatCode_FixMap: If *VariableSizeQ <> #Null - PokeQ(*VariableSizeQ, _MsgPackGetFieldDynamicSize_Within(*MsgPackData, %00001111)) + FastPokeQ(*VariableSizeQ, _MsgPackGetFieldDynamicSize_Within(*MsgPackData, %00001111)) EndIf If *ValueStartOffsetB <> #Null - PokeB(*ValueStartOffsetB, 1) + FastPokeB(*ValueStartOffsetB, 1) EndIf ProcedureReturn #True @@ -132,10 +132,10 @@ Procedure _MsgPackGetFieldSpacingInfo(*MsgPackData.MsgPackData, ExaminedDataType #MsgPack_FormatCode_Str8, #MsgPack_FormatCode_Bin8: If *VariableSizeQ <> #Null - PokeQ(*VariableSizeQ, _MsgPackGetFieldDynamicSize_1After(*MsgPackData)) + FastPokeQ(*VariableSizeQ, _MsgPackGetFieldDynamicSize_1After(*MsgPackData)) EndIf If *ValueStartOffsetB <> #Null - PokeB(*ValueStartOffsetB, 2) + FastPokeB(*ValueStartOffsetB, 2) EndIf ProcedureReturn #True @@ -146,10 +146,10 @@ Procedure _MsgPackGetFieldSpacingInfo(*MsgPackData.MsgPackData, ExaminedDataType #MsgPack_FormatCode_Array16, #MsgPack_FormatCode_Map16: If *VariableSizeQ <> #Null - PokeQ(*VariableSizeQ, _MsgPackGetFieldDynamicSize_2After(*MsgPackData)) + FastPokeQ(*VariableSizeQ, _MsgPackGetFieldDynamicSize_2After(*MsgPackData)) EndIf If *ValueStartOffsetB <> #Null - PokeB(*ValueStartOffsetB, 3) + FastPokeB(*ValueStartOffsetB, 3) EndIf ProcedureReturn #True @@ -160,19 +160,19 @@ Procedure _MsgPackGetFieldSpacingInfo(*MsgPackData.MsgPackData, ExaminedDataType #MsgPack_FormatCode_Array32, #MsgPack_FormatCode_Map32: If *VariableSizeQ <> #Null - PokeQ(*VariableSizeQ, _MsgPackGetFieldDynamicSize_4After(*MsgPackData)) + FastPokeQ(*VariableSizeQ, _MsgPackGetFieldDynamicSize_4After(*MsgPackData)) EndIf If *ValueStartOffsetB <> #Null - PokeB(*ValueStartOffsetB, 5) + FastPokeB(*ValueStartOffsetB, 5) EndIf ProcedureReturn #True Default: If *VariableSizeQ <> #Null - PokeQ(*VariableSizeQ, #MsgPack_InvalidSize) + FastPokeQ(*VariableSizeQ, #MsgPack_InvalidSize) EndIf If *ValueStartOffsetB <> #Null - PokeB(*ValueStartOffsetB, #MsgPack_InvalidSize) + FastPokeB(*ValueStartOffsetB, #MsgPack_InvalidSize) EndIf ProcedureReturn #False EndSelect @@ -269,7 +269,7 @@ Procedure.MsgPack_ErrorCode _MsgPackGetFieldLayout(*MsgPackData.MsgPackData, *He *ChildCount\q = ChildCount Default: - Debug("Invalid format code ! (" + RSet(Hex(PeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset)), 2, "0") + ")") + Debug("Invalid format code ! (" + RSet(Hex(FastPeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset)), 2, "0") + ")") *MsgPackData\LastError = #MsgPack_Error_InvalidFormatCode ProcedureReturn #MsgPack_Error_InvalidFormatCode EndSelect @@ -341,7 +341,7 @@ Procedure.MsgPack_ErrorCode _MsgPackSkipFields(*MsgPackData.MsgPackData, FieldCo EndIf ; Arrays and maps are at depth `Level + 1` from the structure's content. - FormatByte = PeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset) + FormatByte = FastPeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset) If _MsgPackIsContainerFormatByte(FormatByte) And *MsgPackData\IteratorDepth + Level + 1 > #MsgPack_MaxDepth Debug("Arrays and maps are nested deeper than " + Str(#MsgPack_MaxDepth) + " levels !") *MsgPackData\LastError = #MsgPack_Error_MaxDepthExceeded @@ -424,7 +424,7 @@ Procedure.q MsgPackGetEntryCount(*MsgPackData.MsgPackData) ProcedureReturn ChildCount / 2 EndSelect - Debug("Unexpected format code ! (" + RSet(Hex(PeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset)), 2, "0") + ")") + Debug("Unexpected format code ! (" + RSet(Hex(FastPeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset)), 2, "0") + ")") *MsgPackData\LastError = #MsgPack_Error_InvalidFormatCode ProcedureReturn #MsgPack_InvalidSize EndProcedure @@ -486,7 +486,7 @@ Procedure.i MsgPackExamine(*MsgPackData.MsgPackData, ExaminationOptions.MsgPack_ DataType = MsgPackFormatCodeToDataType(MsgPackGetFormatCode(*MsgPackData)) If DataType <> #MsgPack_DataTypes_Array And DataType <> #MsgPack_DataTypes_Map Debug("Attempted to examine format code 0x" + - RSet(Hex(PeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset)), 2, "0") + + RSet(Hex(FastPeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset)), 2, "0") + " as if it was an array or map !") *MsgPackData\LastError = #MsgPack_Error_InvalidFormatCode ProcedureReturn #Null diff --git a/Includes/_Literals.pbi b/Includes/_Literals.pbi index 8f64401..9acaa3b 100644 --- a/Includes/_Literals.pbi +++ b/Includes/_Literals.pbi @@ -72,13 +72,13 @@ Procedure.b MsgPackReadBoolean(*MsgPackData.MsgPackData) ; We don't check if we're 1 byte off the end since the previous check implies it. - If PeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset) = #MsgPack_FormatCode_False + If FastPeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset) = #MsgPack_FormatCode_False If _MsgPackHasFlag(*MsgPackData, #MsgPack_DataFlags_MoveOffsetAfterRead) *MsgPackData\BufferOffset = *MsgPackData\BufferOffset + 1 EndIf ProcedureReturn #False - ElseIf PeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset) = #MsgPack_FormatCode_True + ElseIf FastPeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset) = #MsgPack_FormatCode_True If _MsgPackHasFlag(*MsgPackData, #MsgPack_DataFlags_MoveOffsetAfterRead) *MsgPackData\BufferOffset = *MsgPackData\BufferOffset + 1 EndIf @@ -86,7 +86,7 @@ Procedure.b MsgPackReadBoolean(*MsgPackData.MsgPackData) ProcedureReturn #True Else Debug("The format code isn't the one for a boolean ! (" + - RSet(Hex(PeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset)), 2, "0") + + RSet(Hex(FastPeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset)), 2, "0") + " vs "+ RSet(Hex(#MsgPack_FormatCode_False), 2, "0") + "/"+ RSet(Hex(#MsgPack_FormatCode_True), 2, "0") + ")") @@ -128,7 +128,7 @@ Procedure.MsgPack_ErrorCode _MsgPackWriteLiteral(*MsgPackData.MsgPackData, Liter EndIf EndIf - PokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, LiteralFormatCode) + FastPokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, LiteralFormatCode) If _MsgPackHasFlag(*MsgPackData, #MsgPack_DataFlags_MoveOffsetAfterWrite) *MsgPackData\BufferOffset = *MsgPackData\BufferOffset + 1 diff --git a/Includes/_Primitives.pbi b/Includes/_Primitives.pbi index fb0ee8c..2afdd15 100644 --- a/Includes/_Primitives.pbi +++ b/Includes/_Primitives.pbi @@ -91,9 +91,9 @@ Procedure.MsgPack_ErrorCode _MsgPackExpectRead(*MsgPackData.MsgPackData, FormatC ProcedureReturn #MsgPack_Error_AtOrPastTheEndOfBuffer EndIf - If PeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset) <> FormatCode + If FastPeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset) <> FormatCode Debug("Unexpected format code ! (" + - RSet(Hex(PeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset)), 2, "0") + + RSet(Hex(FastPeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset)), 2, "0") + " vs "+ RSet(Hex(FormatCode), 2, "0") + ")") *MsgPackData\LastError = #MsgPack_Error_InvalidFormatCode ProcedureReturn #MsgPack_Error_InvalidFormatCode @@ -134,19 +134,19 @@ Procedure.MsgPack_ErrorCode _MsgPackWriteFixedField(*MsgPackData.MsgPackData, Fo Select ValueByteLength Case 0 - PokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode | (Value & $FF)) + FastPokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode | (Value & $FF)) Case 1 - PokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode) - PokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1, Value) + FastPokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode) + FastPokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1, Value) Case 2 - PokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode) - PokeU(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1, EndianSwapU16(Value)) + FastPokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode) + FastPokeU(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1, EndianSwapU16(Value)) Case 4 - PokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode) - PokeL(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1, EndianSwapI32(Value)) + FastPokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode) + FastPokeL(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1, EndianSwapI32(Value)) Case 8 - PokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode) - PokeQ(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1, EndianSwapI64(Value)) + FastPokeA(*MsgPackData\Buffer + *MsgPackData\BufferOffset, FormatCode) + FastPokeQ(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1, EndianSwapI64(Value)) EndSelect *MsgPackData\BufferOffset = *MsgPackData\BufferOffset + 1 + ValueByteLength _MsgPackRewindOffsetAfterWrite(*MsgPackData, 1 + ValueByteLength) @@ -168,13 +168,13 @@ Procedure.q _MsgPackReadFixedField(*MsgPackData.MsgPackData, FormatCode.MsgPack_ Select ValueByteLength Case 1 - ReturnedValue = PeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1) + ReturnedValue = FastPeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1) Case 2 - ReturnedValue = EndianSwapU16(PeekU(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1)) + ReturnedValue = EndianSwapU16(FastPeekU(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1)) Case 4 - ReturnedValue = EndianSwapI32(PeekL(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1)) & $FFFFFFFF + ReturnedValue = EndianSwapI32(FastPeekL(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1)) & $FFFFFFFF Case 8 - ReturnedValue = EndianSwapI64(PeekQ(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1)) + ReturnedValue = EndianSwapI64(FastPeekQ(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1)) EndSelect _MsgPackMoveOffsetAfterRead(*MsgPackData, 1 + ValueByteLength) @@ -359,7 +359,7 @@ Procedure.q MsgPackReadInteger(*MsgPackData.MsgPackData) Case #MsgPack_FormatCode_FixIntPositive, #MsgPack_FormatCode_FixIntNegative: ; The whole byte is the value, both ranges are valid signed bytes. - ReturnedValue = PeekB(*MsgPackData\Buffer + *MsgPackData\BufferOffset) + ReturnedValue = FastPeekB(*MsgPackData\Buffer + *MsgPackData\BufferOffset) _MsgPackMoveOffsetAfterRead(*MsgPackData, 1) *MsgPackData\LastError = #MsgPack_Error_Success ProcedureReturn ReturnedValue @@ -370,7 +370,7 @@ Procedure.q MsgPackReadInteger(*MsgPackData.MsgPackData) Case #MsgPack_FormatCode_UInt32: ProcedureReturn _MsgPackReadFixedField(*MsgPackData, #MsgPack_FormatCode_UInt32, 4) Case #MsgPack_FormatCode_UInt64: - If _MsgPackHasSpaceLeft(*MsgPackData, 9) And (PeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1) & $80) + If _MsgPackHasSpaceLeft(*MsgPackData, 9) And (FastPeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset + 1) & $80) Debug("UInt64 value doesn't fit in a signed quad !") *MsgPackData\LastError = #MsgPack_Error_ValueOverflow ProcedureReturn 0 @@ -386,7 +386,7 @@ Procedure.q MsgPackReadInteger(*MsgPackData.MsgPackData) ProcedureReturn MsgPackReadInt64(*MsgPackData) EndSelect - Debug("Unexpected format code ! (" + RSet(Hex(PeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset)), 2, "0") + ")") + Debug("Unexpected format code ! (" + RSet(Hex(FastPeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset)), 2, "0") + ")") *MsgPackData\LastError = #MsgPack_Error_InvalidFormatCode ProcedureReturn 0 EndProcedure @@ -397,14 +397,14 @@ EndProcedure ; The value's bits are moved and swapped as an integer, since loading a byte-swapped ; float into the FPU can alter its bits. (e.g.: NaN quieting on x87) Procedure.MsgPack_ErrorCode MsgPackWriteFloat32(*MsgPackData.MsgPackData, Value.f) - ProcedureReturn _MsgPackWriteFixedField(*MsgPackData, #MsgPack_FormatCode_Float32, 4, PeekL(@Value)) + ProcedureReturn _MsgPackWriteFixedField(*MsgPackData, #MsgPack_FormatCode_Float32, 4, FastPeekL(@Value)) EndProcedure Procedure.f MsgPackReadFloat32(*MsgPackData.MsgPackData) Protected ReturnedValue.f - PokeL(@ReturnedValue, _MsgPackReadFixedField(*MsgPackData, #MsgPack_FormatCode_Float32, 4)) + FastPokeL(@ReturnedValue, _MsgPackReadFixedField(*MsgPackData, #MsgPack_FormatCode_Float32, 4)) ProcedureReturn ReturnedValue EndProcedure @@ -415,14 +415,14 @@ EndProcedure ; The value's bits are moved and swapped as an integer, since loading a byte-swapped ; float into the FPU can alter its bits. (e.g.: NaN quieting on x87) Procedure.MsgPack_ErrorCode MsgPackWriteFloat64(*MsgPackData.MsgPackData, Value.d) - ProcedureReturn _MsgPackWriteFixedField(*MsgPackData, #MsgPack_FormatCode_Float64, 8, PeekQ(@Value)) + ProcedureReturn _MsgPackWriteFixedField(*MsgPackData, #MsgPack_FormatCode_Float64, 8, FastPeekQ(@Value)) EndProcedure Procedure.d MsgPackReadFloat64(*MsgPackData.MsgPackData) Protected ReturnedValue.d - PokeQ(@ReturnedValue, _MsgPackReadFixedField(*MsgPackData, #MsgPack_FormatCode_Float64, 8)) + FastPokeQ(@ReturnedValue, _MsgPackReadFixedField(*MsgPackData, #MsgPack_FormatCode_Float64, 8)) ProcedureReturn ReturnedValue EndProcedure @@ -454,7 +454,7 @@ Procedure.d MsgPackReadFloat(*MsgPackData.MsgPackData) ProcedureReturn MsgPackReadFloat64(*MsgPackData) EndSelect - Debug("Unexpected format code ! (" + RSet(Hex(PeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset)), 2, "0") + ")") + Debug("Unexpected format code ! (" + RSet(Hex(FastPeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset)), 2, "0") + ")") *MsgPackData\LastError = #MsgPack_Error_InvalidFormatCode ProcedureReturn 0 EndProcedure diff --git a/Includes/_Utils.pbi b/Includes/_Utils.pbi index 3f39e93..d45248f 100644 --- a/Includes/_Utils.pbi +++ b/Includes/_Utils.pbi @@ -46,7 +46,7 @@ Procedure.MsgPack_FormatCode MsgPackGetFormatCode(*MsgPackData.MsgPackData) ProcedureReturn #MsgPack_FormatCode_Invalid EndIf - DataFormatCode = PeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset) + DataFormatCode = FastPeekA(*MsgPackData\Buffer + *MsgPackData\BufferOffset) If DataFormatCode < $80 ; 0x00 - 0x7F