From 89ea27b4ec42d78d6ec9b0086aaa580a2453d6f3 Mon Sep 17 00:00:00 2001 From: chromatic Date: Sat, 16 May 2009 10:35:31 +0000 Subject: [PATCH] [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 --- src/pmc/fixedpmcarray.pmc | 2 +- src/pmc/namespace.pmc | 1 - src/pmc/nci.pmc | 2 +- src/pmc/string.pmc | 3 +-- src/pmc/unmanagedstruct.pmc | 6 ++++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pmc/fixedpmcarray.pmc b/src/pmc/fixedpmcarray.pmc index d7e00b1a23..cdecae0182 100644 --- a/src/pmc/fixedpmcarray.pmc +++ b/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; diff --git a/src/pmc/namespace.pmc b/src/pmc/namespace.pmc index 359160ab5e..b265c14e33 100644 --- a/src/pmc/namespace.pmc +++ b/src/pmc/namespace.pmc @@ -148,7 +148,6 @@ Initialize a C 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); } diff --git a/src/pmc/nci.pmc b/src/pmc/nci.pmc index e358b57db2..d68fb0cee7 100644 --- a/src/pmc/nci.pmc +++ b/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; diff --git a/src/pmc/string.pmc b/src/pmc/string.pmc index 2fa9eb348b..cd626b4024 100644 --- a/src/pmc/string.pmc +++ b/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; diff --git a/src/pmc/unmanagedstruct.pmc b/src/pmc/unmanagedstruct.pmc index 0b83dde91a..d9bd273b5a 100644 --- a/src/pmc/unmanagedstruct.pmc +++ b/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); }