Skip to content

Commit

Permalink
Bind tai to Instant.tai, rather than assigning
Browse files Browse the repository at this point in the history
Since Instants are value types, there is no point wasting a Scalar
on each created Instant.  This makes Instant:D.SET-SELF() about 5x
as fast, and saves one Scalar allocation per Instant.
  • Loading branch information
lizmat committed Jan 4, 2019
1 parent 59bafb8 commit f2ed3db
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/Instant.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ my class Instant is Cool does Real {
# Rakudo::Internals.initial-offset. Thus, $.tai matches TAI from 1970
# to the present.

method SET-SELF($!tai) { self } # cannot be private because of operators
# cannot be private because of operators
method SET-SELF(\tai) { $!tai := tai; self }

method new(*@) { X::Cannot::New.new(class => self).throw }

Expand Down

0 comments on commit f2ed3db

Please sign in to comment.