GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — sqlite: cache the SQLTagStore constructor template · nodejs/node@1dd9dbe

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • env_properties.h
    • node_sqlite.cc
  • test/parallel
    • test-sqlite-template-tag.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/env_properties.h‎

Copy file name to clipboardExpand all lines: src/env_properties.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@
456456
V(sqlite_statement_sync_constructor_template, v8::FunctionTemplate) \
457457
V(sqlite_statement_sync_iterator_constructor_template, v8::FunctionTemplate) \
458458
V(sqlite_session_constructor_template, v8::FunctionTemplate) \
459+
V(sqlite_tag_store_constructor_template, v8::FunctionTemplate) \
459460
V(srv_record_template, v8::DictionaryTemplate) \
460461
V(streambaseoutputstream_constructor_template, v8::ObjectTemplate) \
461462
V(tcp_constructor_template, v8::FunctionTemplate) \
Collapse file

‎src/node_sqlite.cc‎

Copy file name to clipboardExpand all lines: src/node_sqlite.cc
+21-18Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4353,24 +4353,27 @@ static inline void SetSideEffectFreeGetter(
43534353
SQLTagStore::~SQLTagStore() {}
43544354

43554355
Local<FunctionTemplate> SQLTagStore::GetConstructorTemplate(Environment* env) {
4356-
Isolate* isolate = env->isolate();
4357-
Local<FunctionTemplate> tmpl =
4358-
NewFunctionTemplate(isolate, IllegalConstructor);
4359-
tmpl->SetClassName(FIXED_ONE_BYTE_STRING(isolate, "SQLTagStore"));
4360-
tmpl->InstanceTemplate()->SetInternalFieldCount(
4361-
SQLTagStore::kInternalFieldCount);
4362-
SetProtoMethod(isolate, tmpl, "get", Get);
4363-
SetProtoMethod(isolate, tmpl, "all", All);
4364-
SetProtoMethod(isolate, tmpl, "iterate", Iterate);
4365-
SetProtoMethod(isolate, tmpl, "run", Run);
4366-
SetProtoMethod(isolate, tmpl, "clear", Clear);
4367-
SetSideEffectFreeGetter(isolate,
4368-
tmpl,
4369-
FIXED_ONE_BYTE_STRING(isolate, "capacity"),
4370-
CapacityGetter);
4371-
SetSideEffectFreeGetter(
4372-
isolate, tmpl, FIXED_ONE_BYTE_STRING(isolate, "db"), DatabaseGetter);
4373-
SetSideEffectFreeGetter(isolate, tmpl, env->size_string(), SizeGetter);
4356+
Local<FunctionTemplate> tmpl = env->sqlite_tag_store_constructor_template();
4357+
if (tmpl.IsEmpty()) {
4358+
Isolate* isolate = env->isolate();
4359+
tmpl = NewFunctionTemplate(isolate, IllegalConstructor);
4360+
tmpl->SetClassName(FIXED_ONE_BYTE_STRING(isolate, "SQLTagStore"));
4361+
tmpl->InstanceTemplate()->SetInternalFieldCount(
4362+
SQLTagStore::kInternalFieldCount);
4363+
SetProtoMethod(isolate, tmpl, "get", Get);
4364+
SetProtoMethod(isolate, tmpl, "all", All);
4365+
SetProtoMethod(isolate, tmpl, "iterate", Iterate);
4366+
SetProtoMethod(isolate, tmpl, "run", Run);
4367+
SetProtoMethod(isolate, tmpl, "clear", Clear);
4368+
SetSideEffectFreeGetter(isolate,
4369+
tmpl,
4370+
FIXED_ONE_BYTE_STRING(isolate, "capacity"),
4371+
CapacityGetter);
4372+
SetSideEffectFreeGetter(
4373+
isolate, tmpl, FIXED_ONE_BYTE_STRING(isolate, "db"), DatabaseGetter);
4374+
SetSideEffectFreeGetter(isolate, tmpl, env->size_string(), SizeGetter);
4375+
env->set_sqlite_tag_store_constructor_template(tmpl);
4376+
}
43744377
return tmpl;
43754378
}
43764379

Collapse file

‎test/parallel/test-sqlite-template-tag.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-sqlite-template-tag.js
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,12 @@ test('sql.db returns the associated Database instance', () => {
295295
assert.strictEqual(sql.db, db);
296296
});
297297

298+
test('tag stores share a prototype', () => {
299+
const other = new Database(':memory:').createTagStore();
300+
assert.strictEqual(Object.getPrototypeOf(other), Object.getPrototypeOf(sql));
301+
assert.strictEqual(other.constructor, sql.constructor);
302+
});
303+
298304
test('sql error messages are descriptive', () => {
299305
assert.strictEqual(sql.run`INSERT INTO foo (text) VALUES (${'test'})`.changes, 1);
300306

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.