Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

consting & localizing

git-svn-id: https://svn.parrot.org/parrot/trunk@25612 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
commit a35f6fdbf75d9002f8ad238055d455f0f161ebc3 1 parent 84daa67
Andy Lester petdance authored
59 src/pmc/fixedbooleanarray.pmc
View
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2007, The Perl Foundation.
+Copyright (C) 2001-2008, The Perl Foundation.
$Id$
=head1 NAME
@@ -100,12 +100,12 @@ Creates and returns a copy of the array.
*/
PMC *clone() {
- PMC *dest = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const dest = pmc_new(INTERP, SELF->vtable->base_type);
PMC_int_val(dest) = PMC_int_val(SELF);
PMC_int_val2(dest) = PMC_int_val2(SELF);
if (PMC_data(SELF)) {
- PMC_data(dest) = malloc(PMC_int_val2(SELF) / BITS_PER_CHAR);
+ PMC_data(dest) = mem_sys_allocate(PMC_int_val2(SELF) / BITS_PER_CHAR);
mem_sys_memcopy(PMC_data(dest),
PMC_data(SELF), PMC_int_val2(SELF) / BITS_PER_CHAR);
}
@@ -167,7 +167,7 @@ Returns the integer value of the element at index C<key>.
*/
INTVAL get_integer_keyed_int(INTVAL key) {
- Parrot_UInt1 *sd = PMC_data_typed(SELF, Parrot_UInt1 *);
+ const Parrot_UInt1 * const sd = PMC_data_typed(SELF, Parrot_UInt1 *);
if (key < 0 || key >= PMC_int_val(SELF))
real_exception(INTERP, NULL, E_IndexError,
@@ -188,7 +188,7 @@ Returns the integer value of the element at index C<*key>.
INTVAL get_integer_keyed(PMC *key) {
/* simple int keys only */
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
return SELF.get_integer_keyed_int(k);
}
@@ -204,7 +204,7 @@ Returns the floating-point value of the element at index C<key>.
*/
FLOATVAL get_number_keyed_int(INTVAL key) {
- INTVAL i = DYNSELF.get_integer_keyed_int(key);
+ const INTVAL i = DYNSELF.get_integer_keyed_int(key);
return (FLOATVAL)i;
}
@@ -219,7 +219,7 @@ Returns the floating-point value of the element at index C<*key>.
*/
FLOATVAL get_number_keyed(PMC *key) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
return DYNSELF.get_number_keyed_int(k);
}
@@ -234,7 +234,7 @@ Returns the Parrot string value of the element at index C<key>.
*/
STRING *get_string_keyed_int(INTVAL key) {
- PMC *val = DYNSELF.get_pmc_keyed_int(key);
+ PMC * const val = DYNSELF.get_pmc_keyed_int(key);
return VTABLE_get_string(INTERP, val);
}
@@ -249,7 +249,7 @@ Returns the Parrot string value of the element at index C<*key>.
*/
STRING *get_string_keyed(PMC *key) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
return DYNSELF.get_string_keyed_int(k);
}
@@ -265,8 +265,8 @@ Returns the PMC value of the element at index C<key>.
*/
PMC *get_pmc_keyed_int(INTVAL key) {
- PMC *ret = pmc_new(INTERP, enum_class_Boolean);
- INTVAL val = DYNSELF.get_integer_keyed_int(key);
+ PMC * const ret = pmc_new(INTERP, enum_class_Boolean);
+ const INTVAL val = DYNSELF.get_integer_keyed_int(key);
VTABLE_set_integer_native(INTERP, ret, val);
return ret;
}
@@ -282,7 +282,7 @@ Returns the PMC value of the element at index C<*key>.
*/
PMC *get_pmc_keyed(PMC *key) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
return DYNSELF.get_pmc_keyed_int(k);
}
@@ -318,7 +318,7 @@ Sets the integer value of the element at index C<key> to C<value>.
*/
void set_integer_keyed_int(INTVAL key, INTVAL value) {
- Parrot_UInt1 *sd = PMC_data_typed(SELF, Parrot_UInt1 *);
+ Parrot_UInt1 * const sd = PMC_data_typed(SELF, Parrot_UInt1 *);
if (key < 0 || key >= PMC_int_val(SELF))
real_exception(INTERP, NULL, E_IndexError,
@@ -341,7 +341,7 @@ Sets the integer value of the element at index C<key> to C<value>.
*/
void set_integer_keyed(PMC *key, INTVAL value) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
DYNSELF.set_integer_keyed_int(k, value);
}
@@ -372,7 +372,7 @@ C<value>.
*/
void set_number_keyed(PMC *key, FLOATVAL value) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
DYNSELF.set_number_keyed_int(k, value);
}
@@ -388,7 +388,7 @@ Sets the Parrot string value of the element at index C<key> to C<value>.
void set_string_keyed_int(INTVAL key, STRING *value) {
INTVAL tempInt;
- PMC *tempPMC = pmc_new(INTERP, enum_class_Boolean);
+ PMC * const tempPMC = pmc_new(INTERP, enum_class_Boolean);
VTABLE_set_string_native(INTERP, tempPMC, value);
tempInt = VTABLE_get_integer(INTERP, tempPMC);
@@ -408,7 +408,7 @@ C<value>.
*/
void set_string_keyed(PMC *key, STRING *value) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
DYNSELF.set_string_keyed_int(k, value);
}
@@ -423,7 +423,7 @@ Sets the PMC value of the element at index C<key> to C<*src>.
*/
void set_pmc_keyed_int(INTVAL key, PMC *src) {
- INTVAL tempInt = VTABLE_get_integer(INTERP, src);
+ const INTVAL tempInt = VTABLE_get_integer(INTERP, src);
DYNSELF.set_integer_keyed_int(key, tempInt);
}
@@ -439,7 +439,7 @@ C<value>.
*/
void set_pmc_keyed(PMC *key, PMC *value) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
DYNSELF.set_pmc_keyed_int(k, value);
}
@@ -455,7 +455,7 @@ the array.
*/
void push_integer(INTVAL value) {
- INTVAL nextix = DYNSELF.elements();
+ const INTVAL nextix = DYNSELF.elements();
DYNSELF.set_integer_keyed_int(nextix, value);
}
@@ -475,8 +475,8 @@ Used to archive the string.
*/
void freeze(visit_info *info) {
- IMAGE_IO *io = info->image_io;
- STRING *s = string_from_cstring(INTERP,
+ IMAGE_IO * const io = info->image_io;
+ STRING * const s = string_from_cstring(INTERP,
PMC_data_typed(SELF, char *),
PMC_int_val2(SELF) / BITS_PER_CHAR);
@@ -494,12 +494,13 @@ Used to unarchive the string.
*/
void thaw(visit_info *info) {
- IMAGE_IO *io = info->image_io;
+ IMAGE_IO * const io = info->image_io;
SUPER(info);
if (info->extra_flags == EXTRA_IS_NULL) {
- INTVAL size = VTABLE_shift_integer(INTERP, io);
- STRING *s = VTABLE_shift_string(INTERP, io);
+ const INTVAL size = VTABLE_shift_integer(INTERP, io);
+ STRING * const s = VTABLE_shift_string(INTERP, io);
+
PMC_int_val(SELF) = size;
PMC_int_val2(pmc) = s->bufused * BITS_PER_CHAR;
PMC_data(pmc) = mem_sys_allocate_zeroed(s->bufused);
@@ -519,8 +520,8 @@ sets them all to false.
*/
METHOD void fill(INTVAL fill) {
- Parrot_UInt1 *sd = PMC_data_typed(SELF, Parrot_UInt1 *);
- INTVAL j = PMC_int_val(SELF) / BITS_PER_CHAR + 1;
+ Parrot_UInt1 * const sd = PMC_data_typed(SELF, Parrot_UInt1 *);
+ const INTVAL j = PMC_int_val(SELF) / BITS_PER_CHAR + 1;
if (fill)
memset(sd, 0xff, j);
@@ -537,10 +538,6 @@ sets them all to false.
F<docs/pdds/pdd17_basic_types.pod>.
-=head1 HISTORY
-
-Initial version 2004.06.11 by Matt Fowles
-
=cut
*/
38 src/pmc/fixedfloatarray.pmc
View
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2007, The Perl Foundation.
+Copyright (C) 2001-2008, The Perl Foundation.
$Id$
=head1 NAME
@@ -90,7 +90,7 @@ Creates and returns a copy of the array.
PMC *clone() {
INTVAL size;
size_t mem_size;
- PMC *dest = pmc_new(INTERP, SELF->vtable->base_type);
+ PMC * const dest = pmc_new(INTERP, SELF->vtable->base_type);
if (!PMC_data(SELF))
return dest;
@@ -117,7 +117,7 @@ fixed sized array).
*/
INTVAL get_bool() {
- INTVAL size = SELF.elements();
+ const INTVAL size = SELF.elements();
return (INTVAL)(size != 0);
}
@@ -159,7 +159,7 @@ Returns the integer value of the element at index C<key>.
*/
INTVAL get_integer_keyed_int(INTVAL key) {
- FLOATVAL f = DYNSELF.get_number_keyed_int(key);
+ const FLOATVAL f = DYNSELF.get_number_keyed_int(key);
return (INTVAL)f;
}
@@ -175,7 +175,7 @@ Returns the integer value of the element at index C<*key>.
INTVAL get_integer_keyed(PMC *key) {
/* simple int keys only */
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
return DYNSELF.get_integer_keyed_int(k);
}
@@ -212,7 +212,7 @@ Returns the floating-point value of the element at index C<*key>.
*/
FLOATVAL get_number_keyed(PMC *key) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
return DYNSELF.get_number_keyed_int(k);
}
@@ -227,7 +227,7 @@ Returns the Parrot string value of the element at index C<key>.
*/
STRING *get_string_keyed_int(INTVAL key) {
- PMC *e = DYNSELF.get_pmc_keyed_int(key);
+ PMC * const e = DYNSELF.get_pmc_keyed_int(key);
return VTABLE_get_string(INTERP, e);
}
@@ -242,7 +242,7 @@ Returns the Parrot string value of the element at index C<*key>.
*/
STRING *get_string_keyed(PMC *key) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
return DYNSELF.get_string_keyed_int(k);
}
@@ -258,8 +258,8 @@ Returns the PMC value of the element at index C<key>.
*/
PMC *get_pmc_keyed_int(INTVAL key) {
- PMC *ret = pmc_new(INTERP, enum_class_Float);
- FLOATVAL val = DYNSELF.get_number_keyed_int(key);
+ PMC * const ret = pmc_new(INTERP, enum_class_Float);
+ const FLOATVAL val = DYNSELF.get_number_keyed_int(key);
VTABLE_set_number_native(INTERP, ret, val);
return ret;
@@ -276,7 +276,7 @@ Returns the PMC value of the element at index C<*key>.
*/
PMC *get_pmc_keyed(PMC *key) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
return DYNSELF.get_pmc_keyed_int(k);
}
@@ -325,7 +325,7 @@ Sets the integer value of the element at index C<key> to C<value>.
*/
void set_integer_keyed(PMC *key, INTVAL value) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
DYNSELF.set_integer_keyed_int(k, value);
}
@@ -362,7 +362,7 @@ C<value>.
*/
void set_number_keyed(PMC *key, FLOATVAL value) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
DYNSELF.set_number_keyed_int(k, value);
}
@@ -378,7 +378,7 @@ Sets the Parrot string value of the element at index C<key> to C<value>.
void set_string_keyed_int(INTVAL key, STRING *value) {
FLOATVAL tempNum;
- PMC *tempPMC = pmc_new(INTERP, enum_class_Float);
+ PMC * const tempPMC = pmc_new(INTERP, enum_class_Float);
VTABLE_set_string_native(INTERP, tempPMC, value);
tempNum = VTABLE_get_number(INTERP, tempPMC);
@@ -397,7 +397,7 @@ C<value>.
*/
void set_string_keyed(PMC *key, STRING *value) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
DYNSELF.set_string_keyed_int(k, value);
}
@@ -412,7 +412,7 @@ Sets the PMC value of the element at index C<key> to C<*src>.
*/
void set_pmc_keyed_int(INTVAL key, PMC *src) {
- FLOATVAL tempNum = VTABLE_get_number(INTERP, src);
+ const FLOATVAL tempNum = VTABLE_get_number(INTERP, src);
DYNSELF.set_number_keyed_int(key, tempNum);
}
@@ -428,7 +428,7 @@ C<value>.
*/
void set_pmc_keyed(PMC *key, PMC *value) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
DYNSELF.set_pmc_keyed_int(k, value);
}
@@ -442,10 +442,6 @@ C<value>.
F<docs/pdds/pdd17_basic_types.pod>.
-=head1 HISTORY
-
-Initial version 2004.06.11 by Matt Fowles
-
=cut
*/
90 src/pmc/fixedintegerarray.pmc
View
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2007, The Perl Foundation.
+Copyright (C) 2001-2008, The Perl Foundation.
$Id$
=head1 NAME
@@ -57,7 +57,7 @@ in the constant PMC pool.
*/
PMC *new_from_string(STRING *rep, INTVAL flags) {
- INTVAL type = SELF->vtable->base_type;
+ const INTVAL type = SELF->vtable->base_type;
INTVAL n, elem, i, l;
char *p, *start;
int base;
@@ -174,8 +174,6 @@ Creates and returns a copy of the array.
*/
PMC *clone() {
- INTVAL size;
- PMC *dest;
/* a quick hack to create a clone in the constant PMC arena
* this is needed for the call signatures
*
@@ -183,20 +181,19 @@ Creates and returns a copy of the array.
* vtable
*/
- if (PObj_constant_TEST(SELF))
- dest = constant_pmc_new(INTERP, SELF->vtable->base_type);
- else
- dest = pmc_new(INTERP, SELF->vtable->base_type);
-
- if (!PMC_data(SELF))
- return dest;
+ PMC * const dest =
+ PObj_constant_TEST(SELF)
+ ? constant_pmc_new(INTERP, SELF->vtable->base_type)
+ : pmc_new(INTERP, SELF->vtable->base_type);
- size = PMC_int_val(SELF);
- PMC_int_val(dest) = size;
- PMC_data(dest) = mem_sys_allocate(size * sizeof (INTVAL));
+ if (PMC_data(SELF)) {
+ const INTVAL size = PMC_int_val(SELF);
+ PMC_int_val(dest) = size;
+ PMC_data(dest) = mem_allocate_n_typed(size, INTVAL);
- mem_sys_memcopy(PMC_data(dest), PMC_data(SELF), size * sizeof (INTVAL));
- PObj_active_destroy_SET(dest);
+ mem_sys_memcopy(PMC_data(dest), PMC_data(SELF), size * sizeof (INTVAL));
+ PObj_active_destroy_SET(dest);
+ }
return dest;
}
@@ -212,7 +209,7 @@ fixed sized array).
*/
INTVAL get_bool() {
- INTVAL size = SELF.elements();
+ const INTVAL size = SELF.elements();
return (INTVAL)(size != 0);
}
@@ -276,7 +273,7 @@ Returns the integer value of the element at index C<*key>.
INTVAL get_integer_keyed(PMC *key) {
/* simple int keys only */
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
return DYNSELF.get_integer_keyed_int(k);
}
@@ -292,7 +289,7 @@ Returns the floating-point value of the element at index C<key>.
*/
FLOATVAL get_number_keyed_int(INTVAL key) {
- INTVAL i = DYNSELF.get_integer_keyed_int(key);
+ const INTVAL i = DYNSELF.get_integer_keyed_int(key);
return (FLOATVAL)i;
}
@@ -307,7 +304,7 @@ Returns the floating-point value of the element at index C<*key>.
*/
FLOATVAL get_number_keyed(PMC *key) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
return DYNSELF.get_number_keyed_int(k);
}
@@ -322,7 +319,7 @@ Returns the Parrot string value of the element at index C<key>.
*/
STRING *get_string_keyed_int(INTVAL key) {
- PMC *temp = DYNSELF.get_pmc_keyed_int(key);
+ PMC * const temp = DYNSELF.get_pmc_keyed_int(key);
return VTABLE_get_string(INTERP, temp);
}
@@ -337,13 +334,12 @@ Returns the Parrot string representation C<key>.
*/
STRING *get_repr() {
- STRING *res = CONST_STRING(INTERP, "[ ");
- INTVAL n = VTABLE_elements(INTERP, SELF);
+ STRING *res = CONST_STRING(INTERP, "[ ");
+ const INTVAL n = VTABLE_elements(INTERP, SELF);
INTVAL j;
- PMC *val;
for (j = 0; j < n; ++j) {
- val = SELF.get_pmc_keyed_int(j);
+ PMC * const val = SELF.get_pmc_keyed_int(j);
res = string_append(INTERP, res, VTABLE_get_repr(INTERP, val));
if (j < n - 1)
@@ -366,7 +362,7 @@ Returns the Parrot string value of the element at index C<*key>.
*/
STRING *get_string_keyed(PMC *key) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
return DYNSELF.get_string_keyed_int(k);
}
@@ -382,8 +378,8 @@ Returns the PMC value of the element at index C<key>.
*/
PMC *get_pmc_keyed_int(INTVAL key) {
- PMC *ret = pmc_new(INTERP, enum_class_Integer);
- INTVAL val = DYNSELF.get_integer_keyed_int(key);
+ PMC * const ret = pmc_new(INTERP, enum_class_Integer);
+ const INTVAL val = DYNSELF.get_integer_keyed_int(key);
VTABLE_set_integer_native(INTERP, ret, val);
return ret;
}
@@ -399,7 +395,7 @@ Returns the PMC value of the element at index C<*key>.
*/
PMC *get_pmc_keyed(PMC *key) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
return DYNSELF.get_pmc_keyed_int(k);
}
@@ -454,7 +450,7 @@ Sets the integer value of the element at index C<key> to C<value>.
*/
void set_integer_keyed(PMC *key, INTVAL value) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
DYNSELF.set_integer_keyed_int(k, value);
}
@@ -483,7 +479,7 @@ Sets the floating-point value of the element at index C<key> to C<value>.
*/
void set_number_keyed(PMC *key, FLOATVAL value) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
DYNSELF.set_number_keyed_int(k, value);
}
@@ -499,7 +495,7 @@ Sets the Parrot string value of the element at index C<key> to C<value>.
void set_string_keyed_int(INTVAL key, STRING *value) {
INTVAL tempInt;
- PMC *tempPMC = pmc_new(INTERP, enum_class_Integer);
+ PMC * const tempPMC = pmc_new(INTERP, enum_class_Integer);
VTABLE_set_string_native(INTERP, tempPMC, value);
tempInt = VTABLE_get_integer(INTERP, tempPMC);
DYNSELF.set_integer_keyed_int(key, tempInt);
@@ -516,7 +512,7 @@ Sets the string value of the element at index C<key> to C<value>.
*/
void set_string_keyed(PMC *key, STRING *value) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
DYNSELF.set_string_keyed_int(k, value);
}
@@ -531,7 +527,7 @@ Sets the PMC value of the element at index C<key> to C<*src>.
*/
void set_pmc_keyed_int(INTVAL key, PMC *src) {
- INTVAL tempInt = VTABLE_get_integer(INTERP, src);
+ const INTVAL tempInt = VTABLE_get_integer(INTERP, src);
DYNSELF.set_integer_keyed_int(key, tempInt);
}
@@ -546,7 +542,7 @@ Sets the string value of the element at index C<key> to C<value>.
*/
void set_pmc_keyed(PMC *key, PMC *value) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
DYNSELF.set_pmc_keyed_int(k, value);
}
@@ -590,24 +586,24 @@ Used to unarchive the array.
}
void thaw(visit_info *info) {
- IMAGE_IO *io = info->image_io;
if (info->extra_flags == EXTRA_IS_NULL) {
- INTVAL n = VTABLE_shift_integer(INTERP, io);
- INTVAL i;
- INTVAL *ar;
+ IMAGE_IO * const io = info->image_io;
+ const INTVAL n = VTABLE_shift_integer(INTERP, io);
PMC_int_val(SELF) = 0;
PMC_data(SELF) = NULL;
- if (!n)
- return;
+ if (n) {
+ INTVAL i;
+ INTVAL *ar;
- DYNSELF.set_integer_native(n);
- ar = (INTVAL *)PMC_data(SELF);
+ DYNSELF.set_integer_native(n);
+ ar = (INTVAL *)PMC_data(SELF);
- for (i = 0; i < n; ++i)
- ar[i] = VTABLE_shift_integer(INTERP, io);
+ for (i = 0; i < n; ++i)
+ ar[i] = VTABLE_shift_integer(INTERP, io);
+ }
}
else
SUPER(info);
@@ -622,10 +618,6 @@ Used to unarchive the array.
F<docs/pdds/pdd17_basic_types.pod>.
-=head1 HISTORY
-
-Initial version 2004.06.11 by Matt Fowles
-
=cut
*/
14 src/pmc/fixedpmcarray.pmc
View
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2007, The Perl Foundation.
+Copyright (C) 2001-2008, The Perl Foundation.
$Id$
=head1 NAME
@@ -53,9 +53,9 @@ COMPARE(PARROT_INTERP, void *a, void *b, PMC *cmp)
static void
quicksort(PARROT_INTERP, void **data, UINTVAL n, PMC *cmp)
{
- UINTVAL i, j, ln, rn;
-
while (n > 1) {
+ UINTVAL i, j, ln, rn;
+
swap(&data[0], &data[n/2]);
for (i = 0, j = n; ;) {
@@ -299,7 +299,7 @@ Returns the integer value of the element at index C<key>.
INTVAL get_integer_keyed_int(INTVAL key) {
PMC * const tempPMC = DYNSELF.get_pmc_keyed_int(key);
if (PMC_IS_NULL(tempPMC))
- return 0;
+ return 0;
return VTABLE_get_integer(INTERP, tempPMC);
}
@@ -637,7 +637,7 @@ Sets the PMC at index C<key> to C<value>.
*/
void set_pmc_keyed(PMC *key, PMC *value) {
- INTVAL k = key_integer(INTERP, key);
+ const INTVAL k = key_integer(INTERP, key);
PMC *nextkey = key_next(INTERP, key);
if (!nextkey) {
@@ -829,10 +829,6 @@ Returns TRUE is the element at C<key> is defined; otherwise returns false.
F<docs/pdds/pdd17_basic_types.pod>.
-=head1 HISTORY
-
-Initial version 2004.06.11 by Matt Fowles
-
=cut
*/
49 src/pmc/fixedstringarray.pmc
View
@@ -1,5 +1,5 @@
/*
-Copyright (C) 2001-2007, The Perl Foundation.
+Copyright (C) 2001-2008, The Perl Foundation.
$Id$
=head1 NAME
@@ -88,19 +88,17 @@ Creates and returns a copy of the array.
*/
PMC *clone() {
- PMC * const dest = pmc_new(INTERP, SELF->vtable->base_type);
- INTVAL mem_size, size;
+ PMC * const dest = pmc_new(INTERP, SELF->vtable->base_type);
- if (!PMC_data(SELF))
- return dest;
+ if (PMC_data(SELF)) {
+ const INTVAL size = PMC_int_val(SELF);
+ const INTVAL mem_size = size * sizeof (STRING *);
- size = PMC_int_val(SELF);
- PMC_int_val(dest) = size;
- mem_size = size * sizeof (STRING *);
-
- PMC_data(dest) = mem_sys_allocate(mem_size);
- mem_sys_memcopy(PMC_data(dest), PMC_data(SELF), mem_size);
- PObj_custom_mark_destroy_SETALL(dest);
+ PMC_int_val(dest) = size;
+ PMC_data(dest) = mem_sys_allocate(mem_size);
+ mem_sys_memcopy(PMC_data(dest), PMC_data(SELF), mem_size);
+ PObj_custom_mark_destroy_SETALL(dest);
+ }
return dest;
}
@@ -116,18 +114,15 @@ Marks the array as live.
*/
void mark() {
- int i, end;
- STRING **data;
-
- if (!PMC_data(SELF))
- return;
-
- data = (STRING **) PMC_data(SELF);
- end = PMC_int_val(SELF);
-
- for (i = 0; i < end; i++) {
- if (data[i])
- pobject_lives(INTERP, (PObj *) data[i]);
+ STRING * const * data = (STRING **) PMC_data(SELF);
+ if (data) {
+ const int end = PMC_int_val(SELF);
+ int i;
+
+ for (i = 0; i < end; i++) {
+ if (data[i])
+ pobject_lives(INTERP, (PObj *) data[i]);
+ }
}
}
@@ -220,7 +215,7 @@ Returns the floating-point value of the element at index C<key>.
*/
FLOATVAL get_number_keyed_int(INTVAL key) {
- PMC *tempPMC = DYNSELF.get_pmc_keyed_int(key);
+ PMC * const tempPMC = DYNSELF.get_pmc_keyed_int(key);
return VTABLE_get_number(INTERP, tempPMC);
}
@@ -535,10 +530,6 @@ Used to unarchive the string.
F<docs/pdds/pdd17_basic_types.pod>.
-=head1 HISTORY
-
-Initial version 2004.06.11 by Matt Fowles
-
=cut
*/
Please sign in to comment.
Something went wrong with that request. Please try again.