Replace most trivial uses of slice() with faster list_head() and list_tail()

This commit is contained in:
Garth Minette
2021-03-25 00:23:36 -07:00
parent e9e3616861
commit d7cb503ffc
10 changed files with 112 additions and 51 deletions

View File

@@ -294,9 +294,9 @@ module distribute(spacing=undef, sizes=undef, dir=RIGHT, l=undef)
spc = !is_undef(l)? ((l - sum(gaps)) / ($children-1)) : default(spacing, 10);
gaps2 = [for (gap = gaps) gap+spc];
spos = dir * -sum(gaps2)/2;
spacings = cumsum([0, each gaps2]);
for (i=[0:1:$children-1]) {
totspc = sum(concat([0], slice(gaps2, 0, i)));
$pos = spos + totspc * dir;
$pos = spos + spacings[i] * dir;
$idx = i;
translate($pos) children(i);
}
@@ -339,9 +339,9 @@ module xdistribute(spacing=10, sizes=undef, l=undef)
spc = !is_undef(l)? ((l - sum(gaps)) / ($children-1)) : default(spacing, 10);
gaps2 = [for (gap = gaps) gap+spc];
spos = dir * -sum(gaps2)/2;
spacings = cumsum([0, each gaps2]);
for (i=[0:1:$children-1]) {
totspc = sum(concat([0], slice(gaps2, 0, i)));
$pos = spos + totspc * dir;
$pos = spos + spacings[i] * dir;
$idx = i;
translate($pos) children(i);
}
@@ -384,9 +384,9 @@ module ydistribute(spacing=10, sizes=undef, l=undef)
spc = !is_undef(l)? ((l - sum(gaps)) / ($children-1)) : default(spacing, 10);
gaps2 = [for (gap = gaps) gap+spc];
spos = dir * -sum(gaps2)/2;
spacings = cumsum([0, each gaps2]);
for (i=[0:1:$children-1]) {
totspc = sum(concat([0], slice(gaps2, 0, i)));
$pos = spos + totspc * dir;
$pos = spos + spacings[i] * dir;
$idx = i;
translate($pos) children(i);
}
@@ -429,9 +429,9 @@ module zdistribute(spacing=10, sizes=undef, l=undef)
spc = !is_undef(l)? ((l - sum(gaps)) / ($children-1)) : default(spacing, 10);
gaps2 = [for (gap = gaps) gap+spc];
spos = dir * -sum(gaps2)/2;
spacings = cumsum([0, each gaps2]);
for (i=[0:1:$children-1]) {
totspc = sum(concat([0], slice(gaps2, 0, i)));
$pos = spos + totspc * dir;
$pos = spos + spacings[i] * dir;
$idx = i;
translate($pos) children(i);
}