> [nicholas - Wed Jun 01 11:21:50 2005]: > > This is a bug report for perl from nick@ccl4.org, > generated with the help of perlbug 1.35 running under perl v5.9.3. > > > ----------------------------------------------------------------- > [Please enter your report here] > > We should audit the perl source for all uses of Newz(), to see which > are > wasteful. In many cases we don't need to explicity memzero any of the > freshly allocated memory, as the subsequent code writes to every > location > in it. For example: > > if (!mg->mg_ptr) { > Newz(0, cache, PERL_MAGIC_UTF8_CACHESIZE * 2, STRLEN); > mg->mg_ptr = (char *) cache; > } > assert(cache); > > cache[0] = len; > cache[1] = *offsetp; > /* Drop the stale "length" cache */ > cache[2] = 0; > cache[3] = 0; > > In others, we can make do with zeroing a lot less: > > if (AvARRAY((AV*)sstr)) { > SV **dst_ary, **src_ary; > SSize_t items = AvFILLp((AV*)sstr) + 1; > > src_ary = AvARRAY((AV*)sstr); > Newz(0, dst_ary, AvMAX((AV*)sstr)+1, SV*); > ptr_table_store(PL_ptr_table, src_ary, dst_ary); > SvPV_set(dstr, (char*)dst_ary); > AvALLOC((AV*)dstr) = dst_ary; > if (AvREAL((AV*)sstr)) { > while (items-- > 0) > *dst_ary++ = sv_dup_inc(*src_ary++, param); > } > else { > while (items-- > 0) > *dst_ary++ = sv_dup(*src_ary++, param); > } > items = AvMAX((AV*)sstr) - AvFILLp((AV*)sstr); > while (items-- > 0) { > *dst_ary++ = &PL_sv_undef; > } > > > We may get some speedup here, particularly for ithread duplication. It looks like Newz() is gone from the core, mainly replaced with Newxz(), it appears. Shoule Newxz() be investigated instead?Thread Next