Skip to content

Commit

Permalink
Make creation of typed shaped arrays 15% faster
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Nov 9, 2016
1 parent f06e4c3 commit f5bf6c1
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/core/TypedArray.pm
Expand Up @@ -4,37 +4,37 @@

proto method new(|) { * }
multi method new(:$shape!) {
nqp::if(
set-descriptor(nqp::if(
nqp::defined($shape),set-shape(self,$shape),nqp::create(self)
)!set-descriptor
))
}
multi method new() {
nqp::create(self)!set-descriptor
set-descriptor(nqp::create(self))
}
multi method new(\values, :$shape!) {
nqp::if(
set-descriptor(nqp::if(
nqp::defined($shape),set-shape(self,$shape),nqp::create(self)
)!set-descriptor.STORE(values)
)).STORE(values)
}
multi method new(\values) {
nqp::create(self)!set-descriptor.STORE(values)
set-descriptor(nqp::create(self)).STORE(values)
}
multi method new(**@values is raw, :$shape!) {
nqp::if(
set-descriptor(nqp::if(
nqp::defined($shape),set-shape(self,$shape),nqp::create(self)
)!set-descriptor.STORE(@values)
)).STORE(@values)
}
multi method new(**@values is raw) {
nqp::create(self)!set-descriptor.STORE(@values)
set-descriptor(nqp::create(self)).STORE(@values)
}

method !set-descriptor() is raw {
sub set-descriptor(\list) is raw {
nqp::stmts(
nqp::bindattr(self,Array,'$!descriptor',
nqp::bindattr(list,Array,'$!descriptor',
Perl6::Metamodel::ContainerDescriptor.new(
:of(TValue), :rw(1), :default(TValue))
),
self
list
)
}

Expand Down

0 comments on commit f5bf6c1

Please sign in to comment.