Permalink
Browse files

[PMC] Modified PMC initializations to avoid unnecessary use of

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...
1 parent a67fd50 commit 89ea27b4ec42d78d6ec9b0086aaa580a2453d6f3 @chromatic chromatic committed May 16, 2009
Showing with 7 additions and 7 deletions.
  1. +1 −1 src/pmc/fixedpmcarray.pmc
  2. +0 −1 src/pmc/namespace.pmc
  3. +1 −1 src/pmc/nci.pmc
  4. +1 −2 src/pmc/string.pmc
  5. +4 −2 src/pmc/unmanagedstruct.pmc
View
2 src/pmc/fixedpmcarray.pmc
@@ -373,7 +373,7 @@ array.
return;
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++)
data[i] = PMCNULL;
View
1 src/pmc/namespace.pmc
@@ -148,7 +148,6 @@ Initialize a C<NameSpace> PMC.
mem_allocate_zeroed_typed(Parrot_NameSpace_attributes);
PARROT_NAMESPACE(SELF)->vtable = PMCNULL;
PARROT_NAMESPACE(SELF)->_class = PMCNULL;
- PARROT_NAMESPACE(SELF)->_class = PMCNULL;
SELF.set_pointer(parrot_new_hash(INTERP));
PObj_custom_mark_destroy_SETALL(SELF);
}
View
2 src/pmc/nci.pmc
@@ -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) {
char *sig_c = Parrot_str_to_cstring(interp, sig);
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 i;
View
3 src/pmc/string.pmc
@@ -34,9 +34,8 @@ Initializes the string.
*/
VTABLE void init() {
-
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);
PMC_data(SELF) = attrs;
View
6 src/pmc/unmanagedstruct.pmc
@@ -653,8 +653,8 @@ calc_offsets(PARROT_INTERP, PMC *pmc, PMC *value, size_t toff)
pmclass UnManagedStruct need_ext no_ro {
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 INTVAL size; /* the size of the struct */
/*
@@ -707,7 +707,9 @@ The offset.
*/
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);
}

0 comments on commit 89ea27b

Please sign in to comment.