▲ 0 r/Kotlin

which has better overall performance in this implementation?

between method1 and method2 which has better performance and lower overhead?

ChatGPT says method1 is slightly cheaper but Gemini says method2 is better.

(dont complain about semikolons in the comments, its harder to know if this line is the end of the statement or if it continues in the next line)

@file:JvmName("Suppliers")

import java.util.function.IntSupplier;

@JvmSynthetic
@JvmName("_intSupplierOf")
inline fun intSupplierOf(value: Int): IntSupplier = IntSupplier { value };

@JvmName("intSupplierOf")
fun _intSupplierOf(value: Int): IntSupplier = IntSupplier { value };

class Test {
	fun method1(): Int {
		val x = intSupplierOf(3);
		return x.getAsInt();
	}

	fun method2(): Int {
		val x = _intSupplierOf(3);
		return x.getAsInt();
	}
}

decompiled Java code for reference:

public final class Suppliers {
	// $FF: synthetic method
	@JvmName(
		name = "_intSupplierOf"
	)
	public static final IntSupplier _intSupplierOf(final int value) {
		int $i$f$_intSupplierOf = 0;
		return new IntSupplier() {
			public final int getAsInt() {
				return value;
			}
		};
	}

	@JvmName(
		name = "intSupplierOf"
	)
	@NotNull
	public static final IntSupplier intSupplierOf(int value) {
		return Suppliers::_intSupplierOf$lambda$0;
	}

	private static final int _intSupplierOf$lambda$0(int $value) {
		return $value;
	}
}

public final class Test {
	public final int method1() {
		int value$iv = 3;
		int $i$f$_intSupplierOf = false;
		IntSupplier x = (IntSupplier)(new 1(value$iv));
		return x.getAsInt();
	}

	public final int method2() {
		IntSupplier x = Suppliers.intSupplierOf(3);
		return x.getAsInt();
	}
}
reddit.com
u/Thyristor_Chopper — 3 days ago

i personally very dislike the current Android dev support habits

i know & its a fact that most of the people change their phones very often like every two years, but still, in my opinion i really hate the current Android lifecycle. old phones like Galaxy S4 still performs in a moderately good speed & performance, but just because it has an old Android version, and even because of the pressure caused by Google absolute plonkers app developers these days choose not to support older Android. apps these days require like Android 8.0+ but this seriously need to be changed in the future, it keep the 'working' old phones useless because of this. even there are still many PC program developers that support Windows 7 (and some few even supports XP) but the Android side is too changing fast

reddit.com
u/Thyristor_Chopper — 2 months ago

what is the best PDF annotator for Android 4.4 to use in Galaxy Note 8.0 (GT-N5110)

i tried Adobe Acrobat Reader but it didnt seem to have an eraser and only one color can be used

POLARIS Office 5 has slightly inaccurate pen recognition

S Note (the stock original version) only supports vertical pages when opening horizontal PDFs

reddit.com
u/Thyristor_Chopper — 2 months ago