Skip to content

Commit 184c288

Browse files
committed
Pass raw pointer to javascript in search.
1 parent 834bf1f commit 184c288

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

tsds/ds.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ auto search_add(ds::search_t* search, const std::string& text) -> bool {
102102
}
103103

104104
auto search_execute(ds::search_t* search, const em::val& callback) -> ds::length_t {
105-
return search->execute([&callback](ds::rule_t* candidate) -> bool { return callback(clone(candidate)).as<bool>(); });
105+
return search->execute([&callback](ds::rule_t* candidate) -> bool { return callback(candidate, em::allow_raw_pointers()).as<bool>(); });
106106
}
107107

108108
EMSCRIPTEN_BINDINGS(ds) {

tsds/tsds.mts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@ export class search_t {
215215

216216
execute(callback: (candidate: rule_t) => boolean): number {
217217
return this._search.execute((candidate: dst.Rule): boolean => {
218-
// 由于embind的限制,这里的candidate已经在c++端被复制过一次,在此不需要再次复制。
219-
return callback(new rule_t(candidate));
218+
return callback(new rule_t(candidate).copy());
220219
});
221220
}
222221
}

0 commit comments

Comments
 (0)