Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Prefer append over push?
  • Loading branch information
coke committed Oct 8, 2015
1 parent 5645366 commit e675207
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
24 changes: 12 additions & 12 deletions htmlify.p6
Expand Up @@ -94,7 +94,7 @@ sub recursive-dir($dir) {
take $f;
}
else {
@todo.push($f.path);
@todo.append($f.path);
}
}
}
Expand Down Expand Up @@ -244,7 +244,7 @@ multi write-type-source($doc) {
to the documentation pages for the related types. If not, try the
<a href="/images/type-graph-{uri_escape $podname}.png">PNG
version</a> instead.</p>];
$pod.contents.push: Pod::Raw.new(
$pod.contents.append: Pod::Raw.new(
target => 'html',
contents => $tg-preamble ~ svg-for-file("html/images/type-graph-$podname.svg"),

Expand All @@ -259,7 +259,7 @@ multi write-type-source($doc) {
next unless %routines-by-type{$role};
next if %roles-seen{$role}++;
@roles-todo.append: $role.roles;
$pod.contents.push:
$pod.contents.append:
pod-heading("Routines supplied by role $role"),
pod-block(
"$podname does role ",
Expand All @@ -271,7 +271,7 @@ multi write-type-source($doc) {
}
for @mro -> $class {
next unless %routines-by-type{$class};
$pod.contents.push:
$pod.contents.append:
pod-heading("Routines supplied by class $class"),
pod-block(
"$podname inherits from class ",
Expand All @@ -282,7 +282,7 @@ multi write-type-source($doc) {
;
for $class.roles -> $role {
next unless %routines-by-type{$role};
$pod.contents.push:
$pod.contents.append:
pod-heading("Methods supplied by role $role"),
pod-block(
"$podname inherits from class ",
Expand Down Expand Up @@ -425,7 +425,7 @@ sub find-definitions (:$pod, :$origin, :$min-level = -1) {
]
);
my @orig-chunk = flat $new-head, @pod-section[$i ^.. $new-i];
my $chunk = $created.pod.push: pod-lower-headings(@orig-chunk, :to(%attr<kind> eq 'type' ?? 0 !! 2));
my $chunk = $created.pod.append: pod-lower-headings(@orig-chunk, :to(%attr<kind> eq 'type' ?? 0 !! 2));

if $subkinds eq 'routine' {
# Determine proper subkinds
Expand All @@ -440,7 +440,7 @@ sub find-definitions (:$pod, :$origin, :$min-level = -1) {
$created.categories = @subkinds;
}
if %attr<kind> eq 'routine' {
%routines-by-type{$origin.name}.push: $chunk;
%routines-by-type{$origin.name}.append: $chunk;
write-qualified-method-call(
:$name,
:pod($chunk),
Expand Down Expand Up @@ -475,8 +475,8 @@ sub write-type-graph-images(:$force) {

say 'Writing specialized visualizations to html/images/ ...';
my %by-group = $type-graph.sorted.classify(&viz-group);
%by-group<Exception>.push: $type-graph.types< Exception Any Mu >;
%by-group<Metamodel>.push: $type-graph.types< Any Mu >;
%by-group<Exception>.append: $type-graph.types< Exception Any Mu >;
%by-group<Metamodel>.append: $type-graph.types< Any Mu >;

for %by-group.kv -> $group, @types {
my $viz = Perl6::TypeGraph::Viz.new(:types(@types),
Expand Down Expand Up @@ -551,22 +551,22 @@ sub write-disambiguation-files () {
if $p.elems == 1 {
$p = $p[0] if $p ~~ Array;
if $p.origin -> $o {
$pod.contents.push:
$pod.contents.append:
pod-block(
pod-link("'$name' is a $p.human-kind()", $p.url),
' from ',
pod-link($o.human-kind() ~ ' ' ~ $o.name, $o.url),
);
}
else {
$pod.contents.push:
$pod.contents.append:
pod-block(
pod-link("'$name' is a $p.human-kind()", $p.url)
);
}
}
else {
$pod.contents.push:
$pod.contents.append:
pod-block("'$name' can be anything of the following"),
$p.map({
if .origin -> $o {
Expand Down
4 changes: 2 additions & 2 deletions lib/Perl6/Documentable/Registry.pm
Expand Up @@ -9,7 +9,7 @@ class Perl6::Documentable::Registry {
has @!kinds;
method add-new(*%args) {
die "Cannot add something to a composed registry" if $.composed;
@!documentables.push: my $d = Perl6::Documentable.new(|%args);
@!documentables.append: my $d = Perl6::Documentable.new(|%args);
$d;
}
method compose() {
Expand All @@ -23,7 +23,7 @@ class Perl6::Documentable::Registry {
method lookup(Str $what, Str :$by!) {
unless %!cache{$by}:exists {
for @!documentables -> $d {
%!cache{$by}{$d."$by"()}.push: $d;
%!cache{$by}{$d."$by"()}.append: $d;
}
}
%!cache{$by}{$what};
Expand Down
24 changes: 12 additions & 12 deletions lib/Perl6/TypeGraph/Viz.pm
Expand Up @@ -23,7 +23,7 @@ class Perl6::TypeGraph::Viz {
state %seen;
return if %seen{$n}++;
visit($_) for flat $n.super, $n.roles;
@!types.push: $n;
@!types.append: $n;
}

# Work out in all directions from @.types,
Expand Down Expand Up @@ -54,35 +54,35 @@ class Perl6::TypeGraph::Viz {

method as-dot (:$size) {
my @dot;
@dot.push: "digraph \"perl6-type-graph\" \{\n rankdir=$.rank-dir;\n splines=polyline;\n";
@dot.push: " size=\"$size\"\n" if $size;
@dot.append: "digraph \"perl6-type-graph\" \{\n rankdir=$.rank-dir;\n splines=polyline;\n";
@dot.append: " size=\"$size\"\n" if $size;

if $.dot-hints -> $hints {
@dot.push: "\n // Layout hints\n";
@dot.push: $hints;
@dot.append: "\n // Layout hints\n";
@dot.append: $hints;
}

@dot.push: "\n // Types\n";
@dot.append: "\n // Types\n";
for @.types -> $type {
my $color = $type.packagetype eq 'role' ?? $.role-color !! $.class-color;
@dot.push: " \"$type.name()\" [color=\"$color\", fontcolor=\"$color\", href=\"{$.url-base ~ $type.name }\", fontname=\"FreeSans\"];\n";
@dot.append: " \"$type.name()\" [color=\"$color\", fontcolor=\"$color\", href=\"{$.url-base ~ $type.name }\", fontname=\"FreeSans\"];\n";
}

@dot.push: "\n // Superclasses\n";
@dot.append: "\n // Superclasses\n";
for @.types -> $type {
for $type.super -> $super {
@dot.push: " \"$type.name()\" -> \"$super\" [color=\"$.class-color\"];\n";
@dot.append: " \"$type.name()\" -> \"$super\" [color=\"$.class-color\"];\n";
}
}

@dot.push: "\n // Roles\n";
@dot.append: "\n // Roles\n";
for @.types -> $type {
for $type.roles -> $role {
@dot.push: " \"$type.name()\" -> \"$role\" [color=\"$.role-color\"];\n";
@dot.append: " \"$type.name()\" -> \"$role\" [color=\"$.role-color\"];\n";
}
}

@dot.push: "\}\n";
@dot.append: "\}\n";
return @dot.join;
}

Expand Down
8 changes: 4 additions & 4 deletions lib/Pod/Convenience.pm6
Expand Up @@ -13,12 +13,12 @@ sub pod-gist(Pod::Block $pod, $level = 0) is export {
@chunks = $leading, $pod.^name, (%confs.perl if %confs), "\n";
for $pod.contents.list -> $c {
if $c ~~ Pod::Block {
@chunks.push: pod-gist($c, $level + 2);
@chunks.append: pod-gist($c, $level + 2);
}
elsif $c ~~ Str {
@chunks.push: $c.indent($level + 2), "\n";
@chunks.append: $c.indent($level + 2), "\n";
} elsif $c ~~ Positional {
@chunks.push: $c.map: {
@chunks.append: $c.map: {
if $_ ~~ Pod::Block {
*.&pod-gist
} elsif $_ ~~ Str {
Expand Down Expand Up @@ -101,7 +101,7 @@ sub pod-lower-headings(@content, :$to = 1) is export {
return @content unless $by > $to;
my @new-content;
for @content {
@new-content.push($_ ~~ Pod::Heading
@new-content.append($_ ~~ Pod::Heading
?? Pod::Heading.new: :level(.level - $by + $to) :contents[.contents]
!! $_
);
Expand Down

0 comments on commit e675207

Please sign in to comment.