Skip to content

Commit

Permalink
[PMC] Modified PMC initializations to avoid unnecessary use of
Browse files Browse the repository at this point in the history
mem_allocate_zeroed_* functions, as they're slightly more expensive than
non-zeroed allocations -- especially as these initializers immediately
overwrite allocated memory.

git-svn-id: https://svn.parrot.org/parrot/trunk@38822 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
chromatic committed May 16, 2009
1 parent a67fd50 commit 89ea27b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/pmc/fixedpmcarray.pmc
Expand Up @@ -373,7 +373,7 @@ array.
return; return;


PMC_size(SELF) = size; PMC_size(SELF) = size;
data = mem_allocate_n_zeroed_typed(size, PMC *); data = mem_allocate_n_typed(size, PMC *);


for (i = 0; i < size; i++) for (i = 0; i < size; i++)
data[i] = PMCNULL; data[i] = PMCNULL;
Expand Down
1 change: 0 additions & 1 deletion src/pmc/namespace.pmc
Expand Up @@ -148,7 +148,6 @@ Initialize a C<NameSpace> PMC.
mem_allocate_zeroed_typed(Parrot_NameSpace_attributes); mem_allocate_zeroed_typed(Parrot_NameSpace_attributes);
PARROT_NAMESPACE(SELF)->vtable = PMCNULL; PARROT_NAMESPACE(SELF)->vtable = PMCNULL;
PARROT_NAMESPACE(SELF)->_class = PMCNULL; PARROT_NAMESPACE(SELF)->_class = PMCNULL;
PARROT_NAMESPACE(SELF)->_class = PMCNULL;
SELF.set_pointer(parrot_new_hash(INTERP)); SELF.set_pointer(parrot_new_hash(INTERP));
PObj_custom_mark_destroy_SETALL(SELF); PObj_custom_mark_destroy_SETALL(SELF);
} }
Expand Down
2 changes: 1 addition & 1 deletion src/pmc/nci.pmc
Expand Up @@ -25,7 +25,7 @@ void pcc_params(PARROT_INTERP, STRING *sig, Parrot_NCI_attributes * const nci_in
void pcc_params(PARROT_INTERP, STRING *sig, Parrot_NCI_attributes * const nci_info) { void pcc_params(PARROT_INTERP, STRING *sig, Parrot_NCI_attributes * const nci_info) {
char *sig_c = Parrot_str_to_cstring(interp, sig); char *sig_c = Parrot_str_to_cstring(interp, sig);
size_t sig_length = strlen(sig_c); size_t sig_length = strlen(sig_c);
char *param_sig = mem_allocate_n_zeroed_typed(sig_length, char); char *param_sig = mem_allocate_n_typed(sig_length, char);
size_t j = 0; size_t j = 0;
size_t i; size_t i;


Expand Down
3 changes: 1 addition & 2 deletions src/pmc/string.pmc
Expand Up @@ -34,9 +34,8 @@ Initializes the string.
*/ */


VTABLE void init() { VTABLE void init() {

Parrot_String_attributes *attrs = Parrot_String_attributes *attrs =
mem_allocate_zeroed_typed(Parrot_String_attributes); mem_allocate_typed(Parrot_String_attributes);


attrs->str_val = Parrot_str_new_noinit(INTERP, enum_stringrep_one, 0); attrs->str_val = Parrot_str_new_noinit(INTERP, enum_stringrep_one, 0);
PMC_data(SELF) = attrs; PMC_data(SELF) = attrs;
Expand Down
6 changes: 4 additions & 2 deletions src/pmc/unmanagedstruct.pmc
Expand Up @@ -653,8 +653,8 @@ calc_offsets(PARROT_INTERP, PMC *pmc, PMC *value, size_t toff)


pmclass UnManagedStruct need_ext no_ro { pmclass UnManagedStruct need_ext no_ro {
ATTR void *ptr; /* the struct that this UnManagedStruct isn't managing */ ATTR void *ptr; /* the struct that this UnManagedStruct isn't managing */
ATTR INTVAL size; /* the size of the struct */
ATTR PMC *init; /* the initializer used with this UnManagedStruct */ ATTR PMC *init; /* the initializer used with this UnManagedStruct */
ATTR INTVAL size; /* the size of the struct */


/* /*


Expand Down Expand Up @@ -707,7 +707,9 @@ The offset.
*/ */


VTABLE void init_pmc(PMC *value) { VTABLE void init_pmc(PMC *value) {
SELF.init(); Parrot_UnManagedStruct_attributes *attrs =
mem_allocate_typed(Parrot_UnManagedStruct_attributes);
PMC_data(SELF) = attrs;
SELF.set_pmc(value); SELF.set_pmc(value);
} }


Expand Down

0 comments on commit 89ea27b

Please sign in to comment.