Skip to content

Commit

Permalink
localizing and consting, and flagged a function as constant
Browse files Browse the repository at this point in the history
  • Loading branch information
petdance committed Dec 5, 2010
1 parent c817d4b commit 6507414
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/pmc/fixedbooleanarray.pmc
Expand Up @@ -31,13 +31,15 @@ Auxiliar function to avoid repeating the size evaluation.
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */

PARROT_INLINE
PARROT_CONST_FUNCTION
static UINTVAL get_size_in_bytes(UINTVAL size);

#define ASSERT_ARGS_get_size_in_bytes __attribute__unused__ int _ASSERT_ARGS_CHECK = (0)
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */

PARROT_INLINE
PARROT_CONST_FUNCTION
static UINTVAL
get_size_in_bytes(UINTVAL size)
{
Expand Down Expand Up @@ -125,7 +127,7 @@ Creates and returns a copy of the array.
*/

VTABLE PMC *clone() {
unsigned char * my_bit_array, * clone_bit_array;
unsigned char * my_bit_array;
UINTVAL resize_threshold, size;
PMC * const dest = Parrot_pmc_new(INTERP, SELF->vtable->base_type);

Expand All @@ -134,6 +136,7 @@ Creates and returns a copy of the array.
GET_ATTR_resize_threshold(INTERP, SELF, resize_threshold);

if (my_bit_array) {
unsigned char * clone_bit_array;
const size_t size_in_bytes = get_size_in_bytes(resize_threshold);

SET_ATTR_size(INTERP, dest, size);
Expand Down Expand Up @@ -272,13 +275,12 @@ Returns the Parrot string representation of the array.
*/

VTABLE STRING *get_string() {
STRING *zero, *one;
STRING *str = STRINGNULL;
UINTVAL i;
UINTVAL elems = SELF.elements();
const UINTVAL elems = SELF.elements();

zero = CONST_STRING(INTERP, "0");
one = CONST_STRING(INTERP, "1");
STRING * const zero = CONST_STRING(INTERP, "0");
STRING * const one = CONST_STRING(INTERP, "1");

for (i = 0; i < elems; ++i) {
if (SELF.get_integer_keyed_int((INTVAL)i))
Expand Down

0 comments on commit 6507414

Please sign in to comment.