From 434d1c60be8a83f5b2f5a8d1419fe4ecd2ef68a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Francoeur?= Date: Sun, 13 Jul 2025 11:49:19 -0400 Subject: [PATCH] only initialize DriverPropertyInfo once --- .../src/main/java/tech/turso/TursoConfig.java | 28 +++++++++++-------- .../main/java/tech/turso/core/TursoDB.java | 3 +- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/bindings/java/src/main/java/tech/turso/TursoConfig.java b/bindings/java/src/main/java/tech/turso/TursoConfig.java index 7ed13582c..a3b4b754f 100644 --- a/bindings/java/src/main/java/tech/turso/TursoConfig.java +++ b/bindings/java/src/main/java/tech/turso/TursoConfig.java @@ -7,23 +7,16 @@ import java.util.Properties; /** Turso Configuration. */ public final class TursoConfig { - private Properties pragma; + private static final DriverPropertyInfo[] driverPropertyInfo = driverPropertyInfo(); + + private final Properties pragma; public TursoConfig(Properties properties) { this.pragma = properties; } public static DriverPropertyInfo[] getDriverPropertyInfo() { - return Arrays.stream(Pragma.values()) - .map( - p -> { - DriverPropertyInfo info = new DriverPropertyInfo(p.pragmaName, null); - info.description = p.description; - info.choices = p.choices; - info.required = false; - return info; - }) - .toArray(DriverPropertyInfo[]::new); + return driverPropertyInfo; } public Properties toProperties() { @@ -49,4 +42,17 @@ public final class TursoConfig { return pragmaName; } } + + private static DriverPropertyInfo[] driverPropertyInfo() { + return Arrays.stream(Pragma.values()) + .map( + p -> { + DriverPropertyInfo info = new DriverPropertyInfo(p.pragmaName, null); + info.description = p.description; + info.choices = p.choices; + info.required = false; + return info; + }) + .toArray(DriverPropertyInfo[]::new); + } } diff --git a/bindings/java/src/main/java/tech/turso/core/TursoDB.java b/bindings/java/src/main/java/tech/turso/core/TursoDB.java index 5ebf660ae..8020e685a 100644 --- a/bindings/java/src/main/java/tech/turso/core/TursoDB.java +++ b/bindings/java/src/main/java/tech/turso/core/TursoDB.java @@ -7,7 +7,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.sql.SQLException; - import tech.turso.TursoErrorCode; import tech.turso.annotations.NativeInvocation; import tech.turso.annotations.VisibleForTesting; @@ -38,7 +37,7 @@ public final class TursoDB implements AutoCloseable { * Enum representing different architectures and their corresponding library paths and file * extensions. */ - enum Architecture { + private enum Architecture { MACOS_ARM64("libs/macos_arm64/lib_turso_java.dylib", ".dylib"), MACOS_X86("libs/macos_x86/lib_turso_java.dylib", ".dylib"), LINUX_X86("libs/linux_x86/lib_turso_java.so", ".so"),