Skip to content

Commit

Permalink
tighten up for-loops in Slices, use loop more
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Dec 20, 2024
1 parent 179ccb4 commit 4262204
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions lib/PDL/Slices.pd
Original file line number Diff line number Diff line change
Expand Up @@ -1035,15 +1035,12 @@ sub PDL::rld {
}
EOD
Code => pp_line_numbers(__LINE__, <<'EOF'),
PDL_Indx i,j=0,an;
$GENERIC(b) bv;
PDL_Indx j=0;
loop (n) %{
an = $a();
bv = $b();
for (i=0;i<an;i++) {
$c(m=>j) = bv;
j++;
}
PDL_Indx jlim = j + $a();
$GENERIC(b) bv = $b();
loop (m=j:jlim) %{ $c() = bv; %}
j = jlim;
%}
EOF
Doc => <<'EOD'
Expand Down Expand Up @@ -1202,11 +1199,9 @@ EOC
Code =>pp_line_numbers(__LINE__, <<'EOC'),
PDL_Indx cn=0;
loop (uniqvals) %{
PDL_Indx i, nrows = $a();
for (i=0; i<nrows; i++) {
loop (M) %{ $c(decodedvals=>cn) = $b(); %}
cn++;
}
PDL_Indx cnlim = cn + $a();
loop (decodedvals=cn:cnlim,M) %{ $c() = $b(); %}
cn = cnlim;
%}
EOC
Doc =><<'EOD'
Expand Down Expand Up @@ -1276,9 +1271,8 @@ EOC
PDL_Indx mi=0;
loop (N) %{
PDL_Indx len = $a(), li;
for (li=0; li < len; ++li, ++mi) {
for (li=0; li < len; ++li, ++mi)
$c(M=>mi) = $b() + li;
}
%}
EOC
Doc =><<'EOD'
Expand Down

0 comments on commit 4262204

Please sign in to comment.