Merge pull request 'optimizations' (#5) from develop into main
All checks were successful
/ publish (push) Successful in 1m29s
All checks were successful
/ publish (push) Successful in 1m29s
Reviewed-on: Infendro/bytes-kt#5
This commit was merged in pull request #5.
This commit is contained in:
@@ -1,92 +0,0 @@
|
|||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ develop, main ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ main ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
runs-on: linux
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Java
|
|
||||||
uses: actions/setup-java@v4
|
|
||||||
with:
|
|
||||||
java-version: '24'
|
|
||||||
distribution: 'temurin'
|
|
||||||
|
|
||||||
- name: Cache Gradle
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
key: gradle-${{ hashFiles('**/libs.versions.toml') }}
|
|
||||||
restore-keys: gradle-
|
|
||||||
path: |
|
|
||||||
~/.gradle/caches/
|
|
||||||
~/.gradle/wrapper/
|
|
||||||
|
|
||||||
- name: Cache Konan
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
key: konan-${{ hashFiles('**/libs.versions.toml') }}
|
|
||||||
restore-keys: konan-
|
|
||||||
path: |
|
|
||||||
~/.konan/
|
|
||||||
|
|
||||||
- name: Cache Node
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
key: node-${{ hashFiles('**/libs.versions.toml') }}
|
|
||||||
restore-keys: node-
|
|
||||||
path: |
|
|
||||||
~/.gradle/nodejs
|
|
||||||
~/.gradle/yarn
|
|
||||||
|
|
||||||
- name: Test
|
|
||||||
run: ./gradlew allTests
|
|
||||||
|
|
||||||
publish:
|
|
||||||
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
|
|
||||||
needs: test
|
|
||||||
runs-on: linux
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Java
|
|
||||||
uses: actions/setup-java@v4
|
|
||||||
with:
|
|
||||||
java-version: '24'
|
|
||||||
distribution: 'temurin'
|
|
||||||
|
|
||||||
- name: Cache Gradle
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
key: gradle-${{ hashFiles('**/libs.versions.toml') }}
|
|
||||||
restore-keys: gradle-
|
|
||||||
path: |
|
|
||||||
~/.gradle/caches/
|
|
||||||
~/.gradle/wrapper/
|
|
||||||
|
|
||||||
- name: Cache Konan
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
key: konan-${{ hashFiles('**/libs.versions.toml') }}
|
|
||||||
restore-keys: konan-
|
|
||||||
path: |
|
|
||||||
~/.konan/
|
|
||||||
|
|
||||||
- name: Cache Node
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
key: node-${{ hashFiles('**/libs.versions.toml') }}
|
|
||||||
restore-keys: node-
|
|
||||||
path: |
|
|
||||||
~/.gradle/nodejs
|
|
||||||
~/.gradle/yarn
|
|
||||||
|
|
||||||
- name: Publish
|
|
||||||
run: ./gradlew publish
|
|
||||||
env:
|
|
||||||
INFENDRO__TOKEN: ${{ secrets.TOKEN }}
|
|
||||||
47
.gitea/workflows/publish.yaml
Normal file
47
.gitea/workflows/publish.yaml
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
runs-on: linux
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Java
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: '24'
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: Cache Gradle
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
key: gradle-${{ hashFiles('**/libs.versions.toml') }}
|
||||||
|
restore-keys: gradle-
|
||||||
|
path: |
|
||||||
|
~/.gradle/caches/
|
||||||
|
~/.gradle/wrapper/
|
||||||
|
|
||||||
|
- name: Cache Konan
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
key: konan-${{ hashFiles('**/libs.versions.toml') }}
|
||||||
|
restore-keys: konan-
|
||||||
|
path: |
|
||||||
|
~/.konan/
|
||||||
|
|
||||||
|
- name: Cache Node
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
key: node-${{ hashFiles('**/libs.versions.toml') }}
|
||||||
|
restore-keys: node-
|
||||||
|
path: |
|
||||||
|
~/.gradle/nodejs
|
||||||
|
~/.gradle/yarn
|
||||||
|
|
||||||
|
- name: Publish
|
||||||
|
run: ./gradlew publish
|
||||||
|
env:
|
||||||
|
INFENDRO__TOKEN: ${{ secrets.TOKEN }}
|
||||||
45
.gitea/workflows/test.yaml
Normal file
45
.gitea/workflows/test.yaml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [ main ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: linux
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Java
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: '24'
|
||||||
|
distribution: 'temurin'
|
||||||
|
|
||||||
|
- name: Cache Gradle
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
key: gradle-${{ hashFiles('**/libs.versions.toml') }}
|
||||||
|
restore-keys: gradle-
|
||||||
|
path: |
|
||||||
|
~/.gradle/caches/
|
||||||
|
~/.gradle/wrapper/
|
||||||
|
|
||||||
|
- name: Cache Konan
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
key: konan-${{ hashFiles('**/libs.versions.toml') }}
|
||||||
|
restore-keys: konan-
|
||||||
|
path: |
|
||||||
|
~/.konan/
|
||||||
|
|
||||||
|
- name: Cache Node
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
key: node-${{ hashFiles('**/libs.versions.toml') }}
|
||||||
|
restore-keys: node-
|
||||||
|
path: |
|
||||||
|
~/.gradle/nodejs
|
||||||
|
~/.gradle/yarn
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: ./gradlew allTests
|
||||||
@@ -19,16 +19,18 @@ fun UByteArray.copyInto(
|
|||||||
when (order) {
|
when (order) {
|
||||||
BIG_ENDIAN -> {
|
BIG_ENDIAN -> {
|
||||||
repeat(length / 4) { i ->
|
repeat(length / 4) { i ->
|
||||||
|
val offset = startIndex + (i * 4)
|
||||||
destination[destinationOffset + i] =
|
destination[destinationOffset + i] =
|
||||||
(this[startIndex].toUInt() shl 24) or (this[startIndex + 1].toUInt() shl 16) or
|
(this[offset].toUInt() shl 24) or (this[offset + 1].toUInt() shl 16) or
|
||||||
(this[startIndex + 2].toUInt() shl 8) or this[startIndex + 3].toUInt()
|
(this[offset + 2].toUInt() shl 8) or this[offset + 3].toUInt()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LITTLE_ENDIAN -> {
|
LITTLE_ENDIAN -> {
|
||||||
repeat(length / 4) { i ->
|
repeat(length / 4) { i ->
|
||||||
|
val offset = startIndex + (i * 4)
|
||||||
destination[destinationOffset + i] =
|
destination[destinationOffset + i] =
|
||||||
this[startIndex].toUInt() or (this[startIndex + 1].toUInt() shl 8) or
|
this[offset].toUInt() or (this[offset + 1].toUInt() shl 8) or
|
||||||
(this[startIndex + 2].toUInt() shl 16) or (this[startIndex + 3].toUInt() shl 24)
|
(this[offset + 2].toUInt() shl 16) or (this[offset + 3].toUInt() shl 24)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,21 +58,23 @@ fun UByteArray.copyInto(
|
|||||||
|
|
||||||
when (order) {
|
when (order) {
|
||||||
BIG_ENDIAN -> {
|
BIG_ENDIAN -> {
|
||||||
repeat(length / 4) { i ->
|
repeat(length / 8) { i ->
|
||||||
|
val offset = startIndex + (i * 8)
|
||||||
destination[destinationOffset + i] =
|
destination[destinationOffset + i] =
|
||||||
(this[startIndex].toULong() shl 56) or (this[startIndex + 1].toULong() shl 48) or
|
(this[offset].toULong() shl 56) or (this[offset + 1].toULong() shl 48) or
|
||||||
(this[startIndex + 2].toULong() shl 40) or (this[startIndex + 3].toULong() shl 32) or
|
(this[offset + 2].toULong() shl 40) or (this[offset + 3].toULong() shl 32) or
|
||||||
(this[startIndex + 4].toULong() shl 24) or (this[startIndex + 5].toULong() shl 16) or
|
(this[offset + 4].toULong() shl 24) or (this[offset + 5].toULong() shl 16) or
|
||||||
(this[startIndex + 6].toULong() shl 8) or this[startIndex + 7].toULong()
|
(this[offset + 6].toULong() shl 8) or this[offset + 7].toULong()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LITTLE_ENDIAN -> {
|
LITTLE_ENDIAN -> {
|
||||||
repeat(length / 4) { i ->
|
repeat(length / 8) { i ->
|
||||||
|
val offset = startIndex + (i * 8)
|
||||||
destination[destinationOffset + i] =
|
destination[destinationOffset + i] =
|
||||||
this[startIndex].toULong() or (this[startIndex + 1].toULong() shl 8) or
|
this[offset].toULong() or (this[offset + 1].toULong() shl 8) or
|
||||||
(this[startIndex + 2].toULong() shl 16) or (this[startIndex + 3].toULong() shl 24) or
|
(this[offset + 2].toULong() shl 16) or (this[offset + 3].toULong() shl 24) or
|
||||||
(this[startIndex + 4].toULong() shl 32) or (this[startIndex + 5].toULong() shl 40) or
|
(this[offset + 4].toULong() shl 32) or (this[offset + 5].toULong() shl 40) or
|
||||||
(this[startIndex + 6].toULong() shl 48) or (this[startIndex + 7].toULong() shl 56)
|
(this[offset + 6].toULong() shl 48) or (this[offset + 7].toULong() shl 56)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,8 +45,27 @@ fun UIntArray.copyInto(
|
|||||||
require(startIndex in 0..(size - length))
|
require(startIndex in 0..(size - length))
|
||||||
require(destinationOffset in 0..(destination.size - (length * 4)))
|
require(destinationOffset in 0..(destination.size - (length * 4)))
|
||||||
|
|
||||||
|
when (order) {
|
||||||
|
BIG_ENDIAN -> {
|
||||||
repeat(length) { i ->
|
repeat(length) { i ->
|
||||||
this[startIndex + i].copyInto(destination, destinationOffset + (i * 4), order)
|
val offset = destinationOffset + (i * 4)
|
||||||
|
val value = this[startIndex + i]
|
||||||
|
destination[offset] = (value shr 24).toUByte()
|
||||||
|
destination[offset + 1] = (value shr 16).toUByte()
|
||||||
|
destination[offset + 2] = (value shr 8).toUByte()
|
||||||
|
destination[offset + 3] = value.toUByte()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LITTLE_ENDIAN -> {
|
||||||
|
repeat(length) { i ->
|
||||||
|
val offset = destinationOffset + (i * 4)
|
||||||
|
val value = this[startIndex + i]
|
||||||
|
destination[offset] = value.toUByte()
|
||||||
|
destination[offset + 1] = (value shr 8).toUByte()
|
||||||
|
destination[offset + 2] = (value shr 16).toUByte()
|
||||||
|
destination[offset + 3] = (value shr 24).toUByte()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,8 +53,35 @@ fun ULongArray.copyInto(
|
|||||||
require(startIndex in 0..(size - length))
|
require(startIndex in 0..(size - length))
|
||||||
require(destinationOffset in 0..(destination.size - (length * 8)))
|
require(destinationOffset in 0..(destination.size - (length * 8)))
|
||||||
|
|
||||||
|
when (order) {
|
||||||
|
BIG_ENDIAN -> {
|
||||||
repeat(length) { i ->
|
repeat(length) { i ->
|
||||||
this[startIndex + i].copyInto(destination, destinationOffset + (i * 8), order)
|
val offset = destinationOffset + (i * 8)
|
||||||
|
val value = this[startIndex + i]
|
||||||
|
destination[offset] = (value shr 56).toUByte()
|
||||||
|
destination[offset + 1] = (value shr 48).toUByte()
|
||||||
|
destination[offset + 2] = (value shr 40).toUByte()
|
||||||
|
destination[offset + 3] = (value shr 32).toUByte()
|
||||||
|
destination[offset + 4] = (value shr 24).toUByte()
|
||||||
|
destination[offset + 5] = (value shr 16).toUByte()
|
||||||
|
destination[offset + 6] = (value shr 8).toUByte()
|
||||||
|
destination[offset + 7] = value.toUByte()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LITTLE_ENDIAN -> {
|
||||||
|
repeat(length) { i ->
|
||||||
|
val offset = destinationOffset + (i * 8)
|
||||||
|
val value = this[startIndex + i]
|
||||||
|
destination[offset] = value.toUByte()
|
||||||
|
destination[offset + 1] = (value shr 8).toUByte()
|
||||||
|
destination[offset + 2] = (value shr 16).toUByte()
|
||||||
|
destination[offset + 3] = (value shr 24).toUByte()
|
||||||
|
destination[offset + 4] = (value shr 32).toUByte()
|
||||||
|
destination[offset + 5] = (value shr 40).toUByte()
|
||||||
|
destination[offset + 6] = (value shr 48).toUByte()
|
||||||
|
destination[offset + 7] = (value shr 56).toUByte()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user