Skip to content

Commit 3e70fd5

Browse files
committed
Use faster loop for parameter bind in SQLite
Gets a benchmark doing repeated `execute` calls running in 86% of the time it did before the change.
1 parent b4d162b commit 3e70fd5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/DBDish/SQLite/StatementHandle.pm6

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,9 @@ submethod BUILD(:$!conn!, :$!parent!,
3232
method execute(*@params) {
3333
self!enter-execute(@params.elems, $!param-count);
3434

35-
for @params.kv -> $idx, $v {
36-
self!handle-error(sqlite3_bind($!statement_handle, $idx + 1, $v));
35+
my $num-params = @params.elems;
36+
loop (my $idx = 0; $idx < $num-params; $idx++) {
37+
self!handle-error(sqlite3_bind($!statement_handle, $idx + 1, @params[$idx]));
3738
}
3839
$!row_status = sqlite3_step($!statement_handle);
3940
if $!row_status == SQLITE_ROW | SQLITE_DONE {

0 commit comments

Comments
 (0)