diff --git a/performance/cinterop/src/main/kotlin-native/org/jetbrains/cinteropBenchmarks/structsBenchmark.kt b/performance/cinterop/src/main/kotlin-native/org/jetbrains/cinteropBenchmarks/structsBenchmark.kt index 74baaccff49..23dfaa84efc 100644 --- a/performance/cinterop/src/main/kotlin-native/org/jetbrains/cinteropBenchmarks/structsBenchmark.kt +++ b/performance/cinterop/src/main/kotlin-native/org/jetbrains/cinteropBenchmarks/structsBenchmark.kt @@ -16,6 +16,7 @@ package org.jetbrains.structsBenchmarks import kotlinx.cinterop.* +import platform.posix.* import kotlin.math.sqrt const val benchmarkSize = 10000 @@ -38,7 +39,7 @@ actual fun structBenchmark() { val element = alloc() element.floatValue = i + sqrt(i.toDouble()).toFloat() element.integer = i.toLong() - itoa(i, element.string, 10) + sprintf(element.string, "%d", i) element.contains = containsFunction elementsList.add(element) diff --git a/performance/cinterop/src/nativeInterop/cinterop/struct.def b/performance/cinterop/src/nativeInterop/cinterop/struct.def index fe1595968a2..8e7bfac37b1 100644 --- a/performance/cinterop/src/nativeInterop/cinterop/struct.def +++ b/performance/cinterop/src/nativeInterop/cinterop/struct.def @@ -75,14 +75,6 @@ struct ElementS multiplyElementS(struct ElementS element, int coefficient) { return newElement; } -void itoa(int val, char* buffer, int base){ - int i = 30; - for(; val && i ; --i, val /= base) - buffer[i] = "0123456789abcdef"[val % base]; - buffer[31] = '\0'; - -} - union ElementU* sumElementUPtr(const union ElementU* first, const union ElementU* second) { if (first == NULL || second == NULL) { return NULL; @@ -99,7 +91,7 @@ struct ElementS* sumElementSPtr(const struct ElementS* first, const struct Eleme struct ElementS* newElement = (struct ElementS*)malloc(sizeof(struct ElementS)); newElement->integer = first->integer + second->integer; newElement->floatValue = first->floatValue + second->floatValue; - itoa(newElement->integer, newElement->string, 10); + sprintf(newElement->string, "%d", newElement->integer); return newElement; } \ No newline at end of file