[svn:parrot] r39779 - branches/tt761_keys_revamp/src/pmc
bacek at svn.parrot.org
bacek at svn.parrot.org
Thu Jun 25 21:26:48 UTC 2009
Author: bacek
Date: Thu Jun 25 21:26:47 2009
New Revision: 39779
URL: https://trac.parrot.org/parrot/changeset/39779
Log:
[pmc] Avoid boxing in String's (get|set)_(integer|string)_keyed by
implementing "_int" version of those functions and delegating from
original.
Modified:
branches/tt761_keys_revamp/src/pmc/string.pmc
Modified: branches/tt761_keys_revamp/src/pmc/string.pmc
==============================================================================
--- branches/tt761_keys_revamp/src/pmc/string.pmc Thu Jun 25 21:24:47 2009 (r39778)
+++ branches/tt761_keys_revamp/src/pmc/string.pmc Thu Jun 25 21:26:47 2009 (r39779)
@@ -647,27 +647,42 @@
*/
VTABLE STRING *get_string_keyed(PMC *key) {
+ return SELF.get_string_keyed_int(VTABLE_get_integer(INTERP, key));
+ }
+
+ VTABLE STRING *get_string_keyed_int(INTVAL pos) {
STRING * const s = SELF.get_string();
- const INTVAL k = VTABLE_get_integer(INTERP, key);
- return Parrot_str_substr(INTERP, s, k, 1, NULL, 0);
+ return Parrot_str_substr(INTERP, s, pos, 1, NULL, 0);
}
VTABLE INTVAL get_integer_keyed(PMC *key) {
+ return SELF.get_integer_keyed_int(VTABLE_get_integer(INTERP, key));
+ }
+
+ VTABLE INTVAL get_integer_keyed_int(INTVAL pos) {
STRING * const s = SELF.get_string();
- return string_ord(INTERP, s, VTABLE_get_integer(INTERP, key));
+ return string_ord(INTERP, s, pos);
}
VTABLE void set_string_keyed(PMC *key, STRING * const value) {
+ SELF.set_string_keyed_int(VTABLE_get_integer(INTERP, key), value);
+ }
+
+ VTABLE void set_string_keyed_int(INTVAL pos, STRING * const value) {
STRING * const s = SELF.get_string();
const INTVAL len = Parrot_str_byte_length(INTERP, value);
- Parrot_str_replace(INTERP, s, VTABLE_get_integer(INTERP, key), len, value, NULL);
+ Parrot_str_replace(INTERP, s, pos, len, value, NULL);
VTABLE_set_string_native(INTERP, SELF, s);
}
VTABLE void set_integer_keyed(PMC *key, INTVAL value) {
+ SELF.set_integer_keyed_int(VTABLE_get_integer(INTERP, key), value);
+ }
+
+ VTABLE void set_integer_keyed_int(INTVAL pos, INTVAL value) {
STRING * const s = SELF.get_string();
STRING * const c = string_chr(INTERP, (UINTVAL) value);
- Parrot_str_replace(INTERP, s, VTABLE_get_integer(INTERP, key), 1, c, NULL);
+ Parrot_str_replace(INTERP, s, pos, 1, c, NULL);
VTABLE_set_string_native(INTERP, SELF, s);
}
/*
More information about the parrot-commits
mailing list