Skip to content

Commit

Permalink
Remove the elems method
Browse files Browse the repository at this point in the history
  • Loading branch information
joeri committed Jul 26, 2009
1 parent 19b2a50 commit c225f2c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/builtins/cmp.pir
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ Swiped from Rakudo.
.param pmc a
.param pmc b
.local int i
$I1 = a.'elems'()
$I2 = b.'elems'()
$I1 = elements a
$I2 = elements b
ne $I1, $I2, fail
i = 0
loop:
Expand Down
35 changes: 11 additions & 24 deletions src/classes/Array.pir
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Doesnt work, but it should be close...
unless length goto set_length
goto do_fill
set_length:
length = self.'length'()
length = elements self
length = length - offset
do_fill:
i = offset
Expand Down Expand Up @@ -169,18 +169,6 @@ match:
.return($P0)
.end


=item elems()

Return the number of elements in the list.

=cut

.sub 'elems' :method
$I0 = elements self
.return ($I0)
.end

=item

Return the class name
Expand All @@ -204,19 +192,18 @@ Return a sorted copy of the list
by = get_hll_global 'infix:cmp'
have_by:

.local pmc list, fpa
.local pmc fpa
.local int elems

list = self
elems = list.'elems'()
elems = elements self
fpa = new 'FixedPMCArray'
fpa = elems

.local int i
i = 0
fpa_loop:
unless i < elems goto fpa_end
$P0 = list[i]
$P0 = self[i]
fpa[i] = $P0
inc i
goto fpa_loop
Expand Down Expand Up @@ -250,7 +237,7 @@ Return a sorted copy of the list
hash = new 'CardinalHash'

i = 0
len = self.'elems'()
len = elements self

loop:
if i == len goto done
Expand Down Expand Up @@ -291,7 +278,7 @@ Return a sorted copy of the list
uarray = new 'CardinalArray'

i = 0
len = self.'elems'()
len = elements self

loop:
if i == len goto done
Expand Down Expand Up @@ -400,7 +387,7 @@ Return true is C<self> is of size 0
=cut
.sub 'empty?' :method
.local int len
len = self.'length'()
len = elements self
if len == 0 goto empty
goto not_empty
empty:
Expand Down Expand Up @@ -1129,7 +1116,7 @@ Creates a new Array containing the results and returns it.
Retrieve the number of elements in C<self>

=cut
.sub 'size' :method :vtable('elements')
.sub 'size' :method
$I0 = self
.return($I0)
.end
Expand All @@ -1144,7 +1131,7 @@ Concatenate the passed array onto C<self>
.local int i, len

i = 0
len = other.'size'()
len = elements other

loop:
if i == len goto done
Expand Down Expand Up @@ -1501,7 +1488,7 @@ Operator form for either repetition (when argument is an Integer), or as a short

array = new 'CardinalArray'
hash = new 'CardinalHash'
len = that.'size'()
len = elements that
i = 0

hash_loop:
Expand All @@ -1514,7 +1501,7 @@ Operator form for either repetition (when argument is an Integer), or as a short
goto hash_loop

hash_done:
len = this.'size'()
len = elements this
i = 0

diff_loop:
Expand Down
2 changes: 1 addition & 1 deletion t/12-gather.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ items = gather do
take 2
end

is items.elems, 3, "basic gather"
is items.length, 3, "basic gather"

items.each do |i|
ok i < 3, "basic gather"
Expand Down
2 changes: 1 addition & 1 deletion t/array/array.t
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ a = [ 1, 2, 3, 4 ]
is a.first, 1
is a.first(2).last, 2
is a.last(2).first, 3
is a.elems, 4
is a.length, 4

a = [ 5, 6 ]

Expand Down

0 comments on commit c225f2c

Please sign in to comment.