optimizations #5

Merged
Infendro merged 1 commits from develop into main 2026-01-14 15:12:42 +00:00
6 changed files with 160 additions and 110 deletions
Showing only changes of commit 947ef907a5 - Show all commits

View File

@@ -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 }}

View 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 }}

View 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

View File

@@ -19,16 +19,18 @@ fun UByteArray.copyInto(
when (order) {
BIG_ENDIAN -> {
repeat(length / 4) { i ->
val offset = startIndex + (i * 4)
destination[destinationOffset + i] =
(this[startIndex].toUInt() shl 24) or (this[startIndex + 1].toUInt() shl 16) or
(this[startIndex + 2].toUInt() shl 8) or this[startIndex + 3].toUInt()
(this[offset].toUInt() shl 24) or (this[offset + 1].toUInt() shl 16) or
(this[offset + 2].toUInt() shl 8) or this[offset + 3].toUInt()
}
}
LITTLE_ENDIAN -> {
repeat(length / 4) { i ->
val offset = startIndex + (i * 4)
destination[destinationOffset + i] =
this[startIndex].toUInt() or (this[startIndex + 1].toUInt() shl 8) or
(this[startIndex + 2].toUInt() shl 16) or (this[startIndex + 3].toUInt() shl 24)
this[offset].toUInt() or (this[offset + 1].toUInt() shl 8) or
(this[offset + 2].toUInt() shl 16) or (this[offset + 3].toUInt() shl 24)
}
}
}
@@ -56,21 +58,23 @@ fun UByteArray.copyInto(
when (order) {
BIG_ENDIAN -> {
repeat(length / 4) { i ->
repeat(length / 8) { i ->
val offset = startIndex + (i * 8)
destination[destinationOffset + i] =
(this[startIndex].toULong() shl 56) or (this[startIndex + 1].toULong() shl 48) or
(this[startIndex + 2].toULong() shl 40) or (this[startIndex + 3].toULong() shl 32) or
(this[startIndex + 4].toULong() shl 24) or (this[startIndex + 5].toULong() shl 16) or
(this[startIndex + 6].toULong() shl 8) or this[startIndex + 7].toULong()
(this[offset].toULong() shl 56) or (this[offset + 1].toULong() shl 48) or
(this[offset + 2].toULong() shl 40) or (this[offset + 3].toULong() shl 32) or
(this[offset + 4].toULong() shl 24) or (this[offset + 5].toULong() shl 16) or
(this[offset + 6].toULong() shl 8) or this[offset + 7].toULong()
}
}
LITTLE_ENDIAN -> {
repeat(length / 4) { i ->
repeat(length / 8) { i ->
val offset = startIndex + (i * 8)
destination[destinationOffset + i] =
this[startIndex].toULong() or (this[startIndex + 1].toULong() shl 8) or
(this[startIndex + 2].toULong() shl 16) or (this[startIndex + 3].toULong() shl 24) or
(this[startIndex + 4].toULong() shl 32) or (this[startIndex + 5].toULong() shl 40) or
(this[startIndex + 6].toULong() shl 48) or (this[startIndex + 7].toULong() shl 56)
this[offset].toULong() or (this[offset + 1].toULong() shl 8) or
(this[offset + 2].toULong() shl 16) or (this[offset + 3].toULong() shl 24) or
(this[offset + 4].toULong() shl 32) or (this[offset + 5].toULong() shl 40) or
(this[offset + 6].toULong() shl 48) or (this[offset + 7].toULong() shl 56)
}
}
}

View File

@@ -45,8 +45,27 @@ fun UIntArray.copyInto(
require(startIndex in 0..(size - length))
require(destinationOffset in 0..(destination.size - (length * 4)))
repeat(length) { i ->
this[startIndex + i].copyInto(destination, destinationOffset + (i * 4), order)
when (order) {
BIG_ENDIAN -> {
repeat(length) { i ->
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()
}
}
}
}

View File

@@ -53,8 +53,35 @@ fun ULongArray.copyInto(
require(startIndex in 0..(size - length))
require(destinationOffset in 0..(destination.size - (length * 8)))
repeat(length) { i ->
this[startIndex + i].copyInto(destination, destinationOffset + (i * 8), order)
when (order) {
BIG_ENDIAN -> {
repeat(length) { i ->
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()
}
}
}
}