-
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use SWAR technique for more efficient parsing and serialization on JV…
- Loading branch information
1 parent
44949d8
commit 916e239
Showing
5 changed files
with
215 additions
and
246 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
...ala-core/jvm/src/main/java/com/github/plokhotnyuk/jsoniter_scala/core/ByteArrayAsInt.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.github.plokhotnyuk.jsoniter_scala.core; | ||
|
||
import java.lang.invoke.MethodHandles; | ||
import java.lang.invoke.VarHandle; | ||
import java.nio.ByteOrder; | ||
|
||
class ByteArrayAsInt { // FIXME: Use Java wrapper as w/a for missing support of @PolymorphicSignature methods in Scala 3, see: https://github.com/lampepfl/dotty/issues/11332 | ||
private static final VarHandle VH_INT = | ||
MethodHandles.byteArrayViewVarHandle(int[].class, ByteOrder.LITTLE_ENDIAN); | ||
|
||
static void set(byte[] buf, int pos, int value) { | ||
VH_INT.set(buf, pos, value); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...la-core/jvm/src/main/java/com/github/plokhotnyuk/jsoniter_scala/core/ByteArrayAsLong.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.github.plokhotnyuk.jsoniter_scala.core; | ||
|
||
import java.lang.invoke.MethodHandles; | ||
import java.lang.invoke.VarHandle; | ||
import java.nio.ByteOrder; | ||
|
||
class ByteArrayAsLong { // FIXME: Use Java wrapper as w/a for missing support of @PolymorphicSignature methods in Scala 3, see: https://github.com/lampepfl/dotty/issues/11332 | ||
private static final VarHandle VH_LONG = | ||
MethodHandles.byteArrayViewVarHandle(long[].class, ByteOrder.LITTLE_ENDIAN); | ||
|
||
static void set(byte[] buf, int pos, long value) { | ||
VH_LONG.set(buf, pos, value); | ||
} | ||
|
||
static long get(byte[] buf, int pos) { | ||
return (long) VH_LONG.get(buf, pos); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...a-core/jvm/src/main/java/com/github/plokhotnyuk/jsoniter_scala/core/ByteArrayAsShort.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.github.plokhotnyuk.jsoniter_scala.core; | ||
|
||
import java.lang.invoke.MethodHandles; | ||
import java.lang.invoke.VarHandle; | ||
import java.nio.ByteOrder; | ||
|
||
class ByteArrayAsShort { // FIXME: Use Java wrapper as w/a for missing support of @PolymorphicSignature methods in Scala 3, see: https://github.com/lampepfl/dotty/issues/11332 | ||
private static final VarHandle VH_SHORT = | ||
MethodHandles.byteArrayViewVarHandle(short[].class, ByteOrder.LITTLE_ENDIAN); | ||
|
||
static void set(byte[] buf, int pos, short value) { | ||
VH_SHORT.set(buf, pos, value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.