Skip to content

Commit

Permalink
Avoid repeated use of mixins
Browse files Browse the repository at this point in the history
A mixin causes a global deoptimization at present, which means its costs
are quite high and non-local. We only really need to provide a true 0
when we are actually returning 0, and we can also produce that at
compile time, meaning there's no runtime work at all at runtime. This
gets a hundred thousand insert execute benchmark running in 78% of the
time it did before this change.
  • Loading branch information
jnthn committed Jan 8, 2019
1 parent 2952d67 commit b4d162b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/DBDish/StatementHandle.pm6
Expand Up @@ -24,7 +24,7 @@ has @!column-name;
has @!column-type;

# My defined interface
method execute(*@ --> IntTrue) { ... }
method execute(*@ --> Int) { ... }
method finish(--> Bool) { ... }
method _row(--> Array) { ... }
method _free() { ... }
Expand Down Expand Up @@ -69,7 +69,10 @@ submethod DESTROY() {
}

method rows {
$!affected_rows but IntTrue;
my constant TRUE_ZERO = 0 but IntTrue;
$!affected_rows.defined
?? $!affected_rows || TRUE_ZERO
!! Int
}

method row(:$hash) {
Expand Down

0 comments on commit b4d162b

Please sign in to comment.