Skip to content

Commit ac06fb5

Browse files
committed
Improves dylib lookups by not traversing the file system
1 parent d0c5167 commit ac06fb5

File tree

6 files changed

+84
-24
lines changed

6 files changed

+84
-24
lines changed

cpp/utils.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <fstream>
99
#include <sys/stat.h>
1010
#include <utility>
11+
#include "macros.hpp"
1112

1213
namespace opsqlite {
1314

@@ -322,21 +323,14 @@ void log_to_console(jsi::Runtime &runtime, const std::string &message) {
322323
log.call(runtime, jsi::String::createFromUtf8(runtime, message));
323324
}
324325

325-
inline jsi::Function host_fn(jsi::Runtime &rt, jsi::HostFunctionType lambda) {
326-
return jsi::Function::createFromHostFunction(
327-
rt, jsi::PropNameID::forAscii(rt, ""), 0, std::move(lambda));
328-
};
329-
330326
jsi::Value
331327
promisify(jsi::Runtime &rt, std::function<std::any()> lambda,
332328
std::function<jsi::Value(jsi::Runtime &rt, std::any result)>
333329
resolve_callback) {
334330
auto promise_constructor = rt.global().getPropertyAsFunction(rt, "Promise");
335331

336-
auto executor = host_fn(rt, [lambda = std::move(lambda),
337-
resolve_callback = std::move(resolve_callback)](
338-
jsi::Runtime &rt, const jsi::Value &thiz,
339-
const jsi::Value *args, size_t count) {
332+
auto executor = HFN2(lambda = std::move(lambda),
333+
resolve_callback = std::move(resolve_callback)) {
340334
auto resolve = std::make_shared<jsi::Value>(rt, args[0]);
341335
auto reject = std::make_shared<jsi::Value>(rt, args[1]);
342336

cpp/utils.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ bool file_exists(const std::string &path);
5050

5151
void log_to_console(jsi::Runtime &rt, const std::string &message);
5252

53-
jsi::Function host_fn(jsi::Runtime &rt, jsi::HostFunctionType lambda);
5453
jsi::Value
5554
promisify(jsi::Runtime &rt, std::function<std::any()> lambda,
5655
std::function<jsi::Value(jsi::Runtime &rt, std::any result)>

example/Gemfile.lock

Lines changed: 67 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ GEM
1414
minitest (>= 5.1)
1515
securerandom (>= 0.3)
1616
tzinfo (~> 2.0, >= 2.0.5)
17-
addressable (2.8.7)
18-
public_suffix (>= 2.0.2, < 7.0)
17+
addressable (2.8.8)
18+
public_suffix (>= 2.0.2, < 8.0)
1919
algoliasearch (1.27.5)
2020
httpclient (~> 2.8, >= 2.8.3)
2121
json (>= 1.5.1)
2222
atomos (0.1.3)
2323
base64 (0.3.0)
2424
benchmark (0.5.0)
25-
bigdecimal (3.3.1)
25+
bigdecimal (4.0.1)
2626
claide (1.1.0)
2727
cocoapods (1.15.2)
2828
addressable (~> 2.8)
@@ -63,7 +63,7 @@ GEM
6363
cocoapods-try (1.2.0)
6464
colored2 (3.1.2)
6565
concurrent-ruby (1.3.3)
66-
connection_pool (2.5.4)
66+
connection_pool (3.0.2)
6767
drb (2.2.3)
6868
escape (0.0.4)
6969
ethon (0.15.0)
@@ -86,14 +86,16 @@ GEM
8686
mutex_m
8787
i18n (1.14.7)
8888
concurrent-ruby (~> 1.0)
89-
json (2.16.0)
89+
json (2.18.0)
9090
logger (1.7.0)
91-
minitest (5.26.2)
91+
minitest (6.0.0)
92+
prism (~> 1.5)
9293
molinillo (0.8.0)
9394
mutex_m (0.3.0)
9495
nanaimo (0.3.0)
9596
nap (1.1.0)
9697
netrc (0.11.0)
98+
prism (1.6.0)
9799
public_suffix (4.0.7)
98100
rexml (3.4.4)
99101
ruby-macho (2.5.1)
@@ -133,8 +135,65 @@ DEPENDENCIES
133135
mutex_m
134136
xcodeproj (< 1.26.0)
135137

138+
CHECKSUMS
139+
CFPropertyList (3.0.8) sha256=2c99d0d980536d3d7ab252f7bd59ac8be50fbdd1ff487c98c949bb66bb114261
140+
activesupport (7.2.3) sha256=5675c9770dac93e371412684249f9dc3c8cec104efd0624362a520ae685c7b10
141+
addressable (2.8.8) sha256=7c13b8f9536cf6364c03b9d417c19986019e28f7c00ac8132da4eb0fe393b057
142+
algoliasearch (1.27.5) sha256=26c1cddf3c2ec4bd60c148389e42702c98fdac862881dc6b07a4c0b89ffec853
143+
atomos (0.1.3) sha256=7d43b22f2454a36bace5532d30785b06de3711399cb1c6bf932573eda536789f
144+
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
145+
benchmark (0.5.0) sha256=465df122341aedcb81a2a24b4d3bd19b6c67c1530713fd533f3ff034e419236c
146+
bigdecimal (4.0.1) sha256=8b07d3d065a9f921c80ceaea7c9d4ae596697295b584c296fe599dd0ad01c4a7
147+
claide (1.1.0) sha256=6d3c5c089dde904d96aa30e73306d0d4bd444b1accb9b3125ce14a3c0183f82e
148+
cocoapods (1.15.2) sha256=f0f5153de8d028d133b96f423e04f37fb97a1da0d11dda581a9f46c0cba4090a
149+
cocoapods-core (1.15.2) sha256=322650d97fe1ad4c0831a09669764b888bd91c6d79d0f6bb07281a17667a2136
150+
cocoapods-deintegrate (1.0.5) sha256=517c2a448ef563afe99b6e7668704c27f5de9e02715a88ee9de6974dc1b3f6a2
151+
cocoapods-downloader (2.1) sha256=bb6ebe1b3966dc4055de54f7a28b773485ac724fdf575d9bee2212d235e7b6d1
152+
cocoapods-plugins (1.0.0) sha256=725d17ce90b52f862e73476623fd91441b4430b742d8a071000831efb440ca9a
153+
cocoapods-search (1.0.1) sha256=1b133b0e6719ed439bd840e84a1828cca46425ab73a11eff5e096c3b2df05589
154+
cocoapods-trunk (1.6.0) sha256=5f5bda8c172afead48fa2d43a718cf534b1313c367ba1194cebdeb9bfee9ed31
155+
cocoapods-try (1.2.0) sha256=145b946c6e7747ed0301d975165157951153d27469e6b2763c83e25c84b9defe
156+
colored2 (3.1.2) sha256=b13c2bd7eeae2cf7356a62501d398e72fde78780bd26aec6a979578293c28b4a
157+
concurrent-ruby (1.3.3) sha256=4f9cd28965c4dcf83ffd3ea7304f9323277be8525819cb18a3b61edcb56a7c6a
158+
connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
159+
drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373
160+
escape (0.0.4) sha256=e49f44ae2b4f47c6a3abd544ae77fe4157802794e32f19b8e773cbc4dcec4169
161+
ethon (0.15.0) sha256=0809805a035bc10f54162ca99f15ded49e428e0488bcfe1c08c821e18261a74d
162+
ffi (1.17.2) sha256=297235842e5947cc3036ebe64077584bff583cd7a4e94e9a02fdec399ef46da6
163+
ffi (1.17.2-aarch64-linux-gnu) sha256=c910bd3cae70b76690418cce4572b7f6c208d271f323d692a067d59116211a1a
164+
ffi (1.17.2-aarch64-linux-musl) sha256=69e6556b091d45df83e6c3b19d3c54177c206910965155a6ec98de5e893c7b7c
165+
ffi (1.17.2-arm-linux-gnu) sha256=d4a438f2b40224ae42ec72f293b3ebe0ba2159f7d1bd47f8417e6af2f68dbaa5
166+
ffi (1.17.2-arm-linux-musl) sha256=977dfb7f3a6381206dbda9bc441d9e1f9366bf189a634559c3b7c182c497aaa3
167+
ffi (1.17.2-arm64-darwin) sha256=54dd9789be1d30157782b8de42d8f887a3c3c345293b57ffb6b45b4d1165f813
168+
ffi (1.17.2-x86-linux-gnu) sha256=95d8f9ebea23c39888e2ab85a02c98f54acb2f4e79b829250d7267ce741dc7b0
169+
ffi (1.17.2-x86-linux-musl) sha256=41741449bab2b9530f42a47baa5c26263925306fad0ac2d60887f51af2e3b24c
170+
ffi (1.17.2-x86_64-darwin) sha256=981f2d4e32ea03712beb26e55e972797c2c5a7b0257955d8667ba58f2da6440e
171+
ffi (1.17.2-x86_64-linux-gnu) sha256=05d2026fc9dbb7cfd21a5934559f16293815b7ce0314846fee2ac8efbdb823ea
172+
ffi (1.17.2-x86_64-linux-musl) sha256=97c0eb3981414309285a64dc4d466bd149e981c279a56371ef811395d68cb95c
173+
fourflusher (2.3.1) sha256=1b3de61c7c791b6a4e64f31e3719eb25203d151746bb519a0292bff1065ccaa9
174+
fuzzy_match (2.0.4) sha256=b5de4f95816589c5b5c3ad13770c0af539b75131c158135b3f3bbba75d0cfca5
175+
gh_inspector (1.1.3) sha256=04cca7171b87164e053aa43147971d3b7f500fcb58177698886b48a9fc4a1939
176+
httpclient (2.9.0) sha256=4b645958e494b2f86c2f8a2f304c959baa273a310e77a2931ddb986d83e498c8
177+
i18n (1.14.7) sha256=ceba573f8138ff2c0915427f1fc5bdf4aa3ab8ae88c8ce255eb3ecf0a11a5d0f
178+
json (2.18.0) sha256=b10506aee4183f5cf49e0efc48073d7b75843ce3782c68dbeb763351c08fd505
179+
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
180+
minitest (6.0.0) sha256=4ca597fc1d735ea18d2b4b98c5fb1d5a6da4a6f35ddf32bd5fa3eded33a453be
181+
molinillo (0.8.0) sha256=efbff2716324e2a30bccd3eba1ff3a735f4d5d53ffddbc6a2f32c0ca9433045d
182+
mutex_m (0.3.0) sha256=cfcb04ac16b69c4813777022fdceda24e9f798e48092a2b817eb4c0a782b0751
183+
nanaimo (0.3.0) sha256=aaaedc60497070b864a7e220f7c4b4cad3a0daddda2c30055ba8dae306342376
184+
nap (1.1.0) sha256=949691660f9d041d75be611bb2a8d2fd559c467537deac241f4097d9b5eea576
185+
netrc (0.11.0) sha256=de1ce33da8c99ab1d97871726cba75151113f117146becbe45aa85cb3dabee3f
186+
prism (1.6.0) sha256=bfc0281a81718c4872346bc858dc84abd3a60cae78336c65ad35c8fbff641c6b
187+
public_suffix (4.0.7) sha256=8be161e2421f8d45b0098c042c06486789731ea93dc3a896d30554ee38b573b8
188+
rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142
189+
ruby-macho (2.5.1) sha256=9075e52e0f9270b552a90b24fcc6219ad149b0d15eae1bc364ecd0ac8984f5c9
190+
securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
191+
typhoeus (1.5.0) sha256=120b67ed1ef515e6c0e938176db880f15b0916f038e78ce2a66290f3f1de3e3b
192+
tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b
193+
xcodeproj (1.25.1) sha256=9a2310dccf6d717076e86f602b17c640046b6f1dfe64480044596f6f2f13dc84
194+
136195
RUBY VERSION
137-
ruby 3.3.0p0
196+
ruby 3.3.0
138197

139198
BUNDLED WITH
140-
2.7.2
199+
4.0.1

example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,7 @@ EXTERNAL SOURCES:
20272027
SPEC CHECKSUMS:
20282028
FBLazyVector: 2e5b5553df729e080483373db6f045201ff4e6db
20292029
hermes-engine: 273e30e7fb618279934b0b95ffab60ecedb7acf5
2030-
op-sqlite: e771018121ddfa4373d51bb1e1751835cfa659b0
2030+
op-sqlite: 44765a0bf429dbb8cc5e301b81114faa080df893
20312031
OpServer: 9b3ebdeeb095950e760e3c39853cd06849421b35
20322032
RCTDeprecation: c6b36da89aa26090c8684d29c2868dcca2cd4554
20332033
RCTRequired: 1413a0844770d00fa1f1bb2da4680adfa8698065

example/src/tests/tokenizer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ describe('Tokenizer tests', () => {
1616
});
1717

1818
if (!isLibsql()) {
19+
await db.execute('DROP TABLE IF EXISTS tokenizer_table;');
1920
await db.execute(
2021
`CREATE VIRTUAL TABLE tokenizer_table USING fts5(content, tokenize = 'wordtokenizer');`,
2122
);

ios/OPSQLite.mm

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,18 +73,22 @@ - (NSDictionary *)getConstants {
7373
}
7474

7575
#ifdef OP_SQLITE_USE_CRSQLITE
76-
NSBundle *crsqlite_bundle =
77-
[NSBundle bundleWithIdentifier:@"io.vlcn.crsqlite"];
76+
NSString *crsqlite_bundle_path =
77+
[[[NSBundle mainBundle] privateFrameworksPath]
78+
stringByAppendingPathComponent:@"crsqlite.framework"];
79+
NSBundle *crsqlite_bundle = [NSBundle bundleWithPath:crsqlite_bundle_path];
7880
NSString *crsqlite_path = [crsqlite_bundle pathForResource:@"crsqlite"
7981
ofType:@""];
8082
#else
8183
NSString *crsqlite_path = @"";
8284
#endif
83-
8485

8586
#ifdef OP_SQLITE_USE_SQLITE_VEC
87+
NSString *sqlitevec_bundle_path =
88+
[[[NSBundle mainBundle] privateFrameworksPath]
89+
stringByAppendingPathComponent:@"sqlitevec.framework"];
8690
NSBundle *libsqlitevec_bundle =
87-
[NSBundle bundleWithIdentifier:@"com.ospfranco.sqlitevec"];
91+
[NSBundle bundleWithPath:sqlitevec_bundle_path];
8892
NSString *sqlite_vec_path = [libsqlitevec_bundle pathForResource:@"sqlitevec"
8993
ofType:@""];
9094
#else
@@ -98,7 +102,10 @@ - (NSDictionary *)getConstants {
98102

99103
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(getDylibPath : (
100104
NSString *)bundleId andResource : (NSString *)resourceName) {
101-
NSBundle *bundle = [NSBundle bundleWithIdentifier:bundleId];
105+
NSString *bundle_path = [[[NSBundle mainBundle] privateFrameworksPath]
106+
stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.framework",
107+
resourceName]];
108+
NSBundle *bundle = [NSBundle bundleWithPath:bundle_path];
102109
NSString *path = [bundle pathForResource:resourceName ofType:@""];
103110
return path;
104111
}

0 commit comments

Comments
 (0)