From 1f9726e956242710d7630e4a50adf79598c2d5eb Mon Sep 17 00:00:00 2001 From: Oscar Franco Date: Tue, 19 Nov 2024 04:10:00 +0700 Subject: [PATCH] Turn performance mode into a single boolean --- android/build.gradle | 17 +++++------------ example/ios/Podfile.lock | 8 ++++---- example/package.json | 2 +- lefthook.yml | 35 +++++++++++++++++++++++++++++++++++ op-sqlite.podspec | 17 ++++++----------- 5 files changed, 51 insertions(+), 28 deletions(-) create mode 100644 lefthook.yml diff --git a/android/build.gradle b/android/build.gradle index 632d76f1..032521e5 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -30,7 +30,7 @@ def isNewArchitectureEnabled() { def useSQLCipher = false def useLibsql = false def useCRSQLite = false -def performanceMode = "0" +def performanceMode = false def sqliteFlags = "" def enableFTS5 = false def useSqliteVec = false @@ -53,7 +53,7 @@ if(opsqliteConfig) { useSQLCipher = opsqliteConfig["sqlcipher"] useCRSQLite = opsqliteConfig["crsqlite"] useSqliteVec = opsqliteConfig["sqliteVec"] - performanceMode = opsqliteConfig["performanceMode"] ? opsqliteConfig["performanceMode"] : "" + performanceMode = opsqliteConfig["performanceMode"] sqliteFlags = opsqliteConfig["sqliteFlags"] ? opsqliteConfig["sqliteFlags"] : "" enableFTS5 = opsqliteConfig["fts5"] useLibsql = opsqliteConfig["libsql"] @@ -73,12 +73,8 @@ if(useCRSQLite) { println "[OP-SQLITE] using CR-SQLite 🤖" } -if(performanceMode == "1") { - println "[OP-SQLITE] Thread unsafe performance mode enabled. Use only transactions! 🚀" -} - -if(performanceMode == "2") { - println "[OP-SQLITE] Thread safe performance mode enabled! 🚀" +if(performanceMode) { + println "[OP-SQLITE] Performance mode enabled! 🚀" } if(enableFTS5) { @@ -151,10 +147,7 @@ android { cFlags += "-DOP_SQLITE_USE_CRSQLITE=1" cppFlags += "-DOP_SQLITE_USE_CRSQLITE=1" } - if(performanceMode == '1') { - cFlags += ["-DSQLITE_DQS=0", "-DSQLITE_THREADSAFE=0", "-DSQLITE_DEFAULT_MEMSTATUS=0", "-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1", "-DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1", "-DSQLITE_MAX_EXPR_DEPTH=0", "-DSQLITE_OMIT_DEPRECATED=1", "-DSQLITE_OMIT_PROGRESS_CALLBACK=1", "-DSQLITE_OMIT_SHARED_CACHE=1", "-DSQLITE_USE_ALLOCA=1"] - } - if(performanceMode == '2') { + if(performanceMode) { cFlags += ["-DSQLITE_DQS=0", "-DSQLITE_THREADSAFE=1", "-DSQLITE_DEFAULT_MEMSTATUS=0", "-DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1", "-DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1", "-DSQLITE_MAX_EXPR_DEPTH=0", "-DSQLITE_OMIT_DEPRECATED=1", "-DSQLITE_OMIT_PROGRESS_CALLBACK=1", "-DSQLITE_OMIT_SHARED_CACHE=1", "-DSQLITE_USE_ALLOCA=1"] } if(enableFTS5) { diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 3a80ed7e..d29a99ab 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -10,7 +10,7 @@ PODS: - hermes-engine (0.76.1): - hermes-engine/Pre-built (= 0.76.1) - hermes-engine/Pre-built (0.76.1) - - op-sqlite (10.0.0-tokenizers-beta9): + - op-sqlite (10.1.0): - DoubleConversion - glog - hermes-engine @@ -1540,7 +1540,7 @@ PODS: - React-logger (= 0.76.1) - React-perflogger (= 0.76.1) - React-utils (= 0.76.1) - - RNShare (11.0.4): + - RNShare (11.0.3): - DoubleConversion - glog - hermes-engine @@ -1785,7 +1785,7 @@ SPEC CHECKSUMS: GCDWebServer: 2c156a56c8226e2d5c0c3f208a3621ccffbe3ce4 glog: 08b301085f15bcbb6ff8632a8ebaf239aae04e6a hermes-engine: 46f1ffbf0297f4298862068dd4c274d4ac17a1fd - op-sqlite: 63400939931ca67186f99f8b536a02b048133710 + op-sqlite: 09176c1312198acd6da5847bc0003ce641b4c8f0 RCT-Folly: bf5c0376ffe4dd2cf438dcf86db385df9fdce648 RCTDeprecation: fde92935b3caa6cb65cbff9fbb7d3a9867ffb259 RCTRequired: 75c6cee42d21c1530a6f204ba32ff57335d19007 @@ -1844,7 +1844,7 @@ SPEC CHECKSUMS: React-utils: 5362bd16a9563f9916e7a56c011ddc533507650f ReactCodegen: 865bafc5c17ec2181620ced1a32c39c38ab2951d ReactCommon: 422e364463f33e336fc4db196aeb50fd801d90d6 - RNShare: 4305edead1b8f614ab994046c68193e8d50aaadc + RNShare: e1721a8818a3bf111ed686ed5d8c1dc76b91c8ad SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748 Yoga: db69236006b8b1c6d55ab453390c882306cbf219 diff --git a/example/package.json b/example/package.json index 42cf6b87..4c20633b 100644 --- a/example/package.json +++ b/example/package.json @@ -68,7 +68,7 @@ "op-sqlite": { "sqlcipher": false, "crsqlite": false, - "performanceMode": "2", + "performanceMode": true, "sqliteFlags": "-DSQLITE_TEMP_STORE=2", "iosSqlite": false, "fts5": true, diff --git a/lefthook.yml b/lefthook.yml new file mode 100644 index 00000000..f6e5dfe5 --- /dev/null +++ b/lefthook.yml @@ -0,0 +1,35 @@ +# EXAMPLE USAGE: +# +# Refer for explanation to following link: +# https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md +# +# pre-push: +# commands: +# packages-audit: +# tags: frontend security +# run: yarn audit +# gems-audit: +# tags: backend security +# run: bundle audit +# +# pre-commit: +# parallel: true +# commands: +# eslint: +# glob: "*.{js,ts,jsx,tsx}" +# run: yarn eslint {staged_files} +# rubocop: +# tags: backend style +# glob: "*.rb" +# exclude: '(^|/)(application|routes)\.rb$' +# run: bundle exec rubocop --force-exclusion {all_files} +# govet: +# tags: backend style +# files: git ls-files -m +# glob: "*.go" +# run: go vet {files} +# scripts: +# "hello.js": +# runner: node +# "any.go": +# runner: go run diff --git a/op-sqlite.podspec b/op-sqlite.podspec index 6b45dfff..8b411678 100644 --- a/op-sqlite.podspec +++ b/op-sqlite.podspec @@ -24,7 +24,7 @@ op_sqlite_config = app_package["op-sqlite"] use_sqlcipher = false use_crsqlite = false use_libsql = false -performance_mode = "0" +performance_mode = false phone_version = false sqlite_flags = "" fts5 = false @@ -36,7 +36,7 @@ if(op_sqlite_config != nil) use_sqlcipher = op_sqlite_config["sqlcipher"] == true use_crsqlite = op_sqlite_config["crsqlite"] == true use_libsql = op_sqlite_config["libsql"] == true - performance_mode = op_sqlite_config["performanceMode"] || "0" + performance_mode = op_sqlite_config["performanceMode"] || false phone_version = op_sqlite_config["iosSqlite"] == true sqlite_flags = op_sqlite_config["sqliteFlags"] || "" fts5 = op_sqlite_config["fts5"] == true @@ -136,7 +136,7 @@ Pod::Spec.new do |s| end other_cflags = '-DSQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION=1' - optimizedCflags = other_cflags + '$(inherited) -DSQLITE_DQS=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_OMIT_DEPRECATED=1 -DSQLITE_OMIT_PROGRESS_CALLBACK=1 -DSQLITE_OMIT_SHARED_CACHE=1 -DSQLITE_USE_ALLOCA=1' + optimizedCflags = '$(inherited) -DSQLITE_DQS=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS=1 -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_OMIT_DEPRECATED=1 -DSQLITE_OMIT_PROGRESS_CALLBACK=1 -DSQLITE_OMIT_SHARED_CACHE=1 -DSQLITE_USE_ALLOCA=1 -DSQLITE_THREADSAFE=1' frameworks = [] if fts5 then @@ -156,14 +156,9 @@ Pod::Spec.new do |s| s.library = "sqlite3" end - if performance_mode == '1' then - log_message.call("[OP-SQLITE] Thread unsafe (1) performance mode enabled. Use only transactions! 🚀🚀") - other_cflags = optimizedCflags + ' -DSQLITE_THREADSAFE=0 ' - end - - if performance_mode == '2' then - log_message.call("[OP-SQLITE] Thread safe (2) performance mode enabled 🚀") - other_cflags = optimizedCflags + ' -DSQLITE_THREADSAFE=1 ' + if performance_mode then + log_message.call("[OP-SQLITE] Performance mode enabled, some features might be disabled 🚀") + other_cflags += optimizedCflags end if use_crsqlite then