Skip to content

Commit

Permalink
Efficiency improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrajca committed Dec 12, 2010
1 parent ac6c417 commit 8ba9b28
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
10 changes: 4 additions & 6 deletions src/pmc/nummatrix2d.pmc
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,8 @@ must have two elements.
}

VTABLE void set_string_keyed(PMC * key, STRING * value) {
PMC * const item = get_external_pmc(INTERP, enum_class_Float);
VTABLE_set_string_native(INTERP, item, value);
VTABLE_set_pmc_keyed(INTERP, SELF, key, item);
const FLOATVAL v = Parrot_str_to_num(INTERP, value);
VTABLE_set_number_keyed(INTERP, SELF, key, v);
}

VTABLE void set_pmc_keyed(PMC * key, PMC * value) {
Expand Down Expand Up @@ -511,9 +510,8 @@ Convert the string to a Complex PMC, and set that at the specified location.
}

VTABLE void set_string_keyed_int(INTVAL key, STRING * value) {
PMC * const item = get_external_pmc(INTERP, enum_class_String);
VTABLE_set_string_native(INTERP, item, value);
VTABLE_set_pmc_keyed_int(INTERP, SELF, key, item);
const FLOATVAL v = Parrot_str_to_num(INTERP, value);
VTABLE_set_number_keyed_int(INTERP, SELF, key, v);
}


Expand Down
10 changes: 4 additions & 6 deletions t/pmc/nummatrix2d.t
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,12 @@ method test_VTABLE_set_string_keyed() {
my $a;
Q:PIR {
$P0 = find_lex "$m"
$S0 = "15.0"
$P0[0;0] = $S0
$P0[0;0] = "15.2"
$N1 = $P0[0;0]
$P1 = box $N1
store_lex "$a", $P1
};
assert_equal($a, 15.0, "set_string_key failed");
assert_equal($a, 15.2, "set_string_key failed");
}
method test_VTABLE_set_string_keyed_int() {
Expand All @@ -254,12 +253,11 @@ method test_VTABLE_set_string_keyed_int() {
my $a;
Q:PIR {
$P0 = find_lex "$m"
$S0 = "15.0"
$P0[0] = $S0
$P0[0] = "15.2"
$N1 = $P0[0]
$P1 = box $N1
store_lex "$a", $P1
};
assert_equal($a, 15.0, "set_string_key_int failed");
assert_equal($a, 15.2, "set_string_key_int failed");
}

0 comments on commit 8ba9b28

Please sign in to comment.