Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Revert "Possibly speed it up, but may have made it slower"
This reverts commit a6aa668.
  • Loading branch information
samcv committed Jan 17, 2017
1 parent a6aa668 commit 43098cc
Showing 1 changed file with 21 additions and 42 deletions.
63 changes: 21 additions & 42 deletions UCD-gen.p6
Expand Up @@ -365,33 +365,21 @@ sub make-point-index (:$less) {
}
sub make-bitfield-rows {
note "Making bitfield-rows…";
my int $i = 0;
my %code-to-prop{Int};
my %prop-to-code;
my Int $i = 0;
my str $binary-struct-str;
# Create the order of the struct
my str $header = "struct binary_prop_bitfield \{\n";
my %nqp-prop-to-code = nqp::hash;
my %nqp-code-to-prop = nqp::hash;
my %nqp-bin-prop-to-code = nqp::hash;
my %nqp-bin-code-to-prop = nqp::hash;
for %binary-properties.keys.sort -> $bin-prop {
my str $i_s = nqp::base_I(nqp::decont($i), 10);
nqp::bindkey(%nqp-bin-prop-to-code, $bin-prop, $i_s);
nqp::bindkey(%nqp-bin-code-to-prop, $i_s, $bin-prop);

nqp::bindkey(%nqp-prop-to-code, $bin-prop, $i_s);
nqp::bindkey(%nqp-code-to-prop, $i_s, $bin-prop);
for %binary-properties.keys.sort -> $bin {
%prop-to-code{$bin} = $i;
%code-to-prop{$i} = $bin;
$i++;
$header = nqp::concat($header," unsigned int $bin-prop :1;\n");
$header = nqp::concat($header," unsigned int $bin :1;\n");
}
my %nqp-enum-prop-to-code = nqp::hash;
my %nqp-enum-code-to-prop = nqp::hash;
for %enumerated-properties.keys.sort -> $property {
my str $i_s = nqp::base_I(nqp::decont($i), 10);
nqp::bindkey(%nqp-enum-prop-to-code, $property, $i_s);
nqp::bindkey(%nqp-enum-code-to-prop, $i_s, $property);

nqp::bindkey(%nqp-prop-to-code, $property, $i_s);
nqp::bindkey(%nqp-code-to-prop, $i_s, $property);
%prop-to-code{$property} = $i;
%code-to-prop{$i} = $property;
$i++;
my $bitwidth = %enumerated-properties{$property}<bitwidth>;
$header = nqp::concat($header, " unsigned int $property :$bitwidth;\n");
Expand All @@ -400,37 +388,28 @@ sub make-bitfield-rows {
$header = nqp::concat($header, "typedef struct binary_prop_bitfield binary_prop_bitfield;\n");
my $bitfield-rows := nqp::list_s;
my %bitfield-rows-seen = nqp::hash;
my @code-to-prop-keys = %nqp-code-to-prop.keys.sort(+*).».Str;
my @code-to-prop-keys = %code-to-prop.keys.sort(+*);
my $t1 = now;
quietly for %points.keys.sort(+*) -> $point {
my $bitfield-columns := nqp::list_s;
for @code-to-prop-keys -> $propcode {
my str $prop = nqp::atkey(%nqp-code-to-prop, $propcode);
my %points-point = nqp::atkey(%points, $point);
if nqp::existskey(%points-point, $prop) {
if nqp::existskey(%nqp-bin-prop-to-code, $prop) {
nqp::push_s($bitfield-columns,
nqp::unbox_s(
nqp::atkey(%points-point, $prop) ?? '1' !! '0'
)
)
my $prop = %code-to-prop{$propcode};
if %points{$point}{$prop}:exists {
if nqp::existskey(%binary-properties, $prop) {
nqp::push_s($bitfield-columns, nqp::unbox_s(%points{$point}{$prop} ?? '1' !! '0'));
}
elsif nqp::existskey(%nqp-enum-prop-to-code, $prop) {
# get the value of the point's enum property
my str $enum_s = nqp::base_I(nqp::decont(%points-point{$prop}), 10);
# If the value exists we need to look up the value
if %enumerated-properties{$prop}{$enum_s}:exists {
nqp::push_s($bitfield-columns,
nqp::base_I(
nqp::decont(%enumerated-properties{$prop}{$enum_s}), 10
)
);
elsif nqp::existskey(%enumerated-properties, $prop) {
my $enum := %points{$point}{$prop};
# If the key exists we need to look up the value
if %enumerated-properties{$prop}{$enum}:exists {
$enum := %enumerated-properties{$prop}{ $enum };
nqp::push_s($bitfield-columns, nqp::base_I(nqp::decont($enum),10));
}
# If it doesn't exist it's an Int property. Eventually we should try and look
# up the enum type in the hash
# XXX make it so we have consistent functionality for Int and non Int enums
else {
nqp::push_s($bitfield-columns, $enum_s);
nqp::push_s($bitfield-columns, nqp::base_I(nqp::decont($enum),10));
}
}
else {
Expand Down

0 comments on commit 43098cc

Please sign in to comment.