develooper Front page | perl.perl5.porters | Postings from March 2014

[perl #116925] document/publicize THINKFIRST

Thread Previous
From:
Tony Cook via RT
Date:
March 26, 2014 05:08
Subject:
[perl #116925] document/publicize THINKFIRST
Message ID:
rt-4.0.18-25527-1395810476-632.116925-15-0@perl.org
On Wed Feb 05 01:57:24 2014, bulk88 wrote:
> The problem is SvPV_force_nolen and SvPVbyte_force_nolen do something
> totally useless if you just want to write into them. If I am going to
> just write, why do I want to A. copy the COW contents to a new non-COW
> block, B. convert encodings, then write over it? I want a
> uninitialized PV. sv_force_normal() copies the COW data over. Some
> people want R/W buffers to manipulate in place the data too.

I think:

  sv_force_normal_flags(sv, SV_COW_DROP_PV);
  SvUPGRADE(sv, SVt_PV);
  // SvGROW etc

is the answer there, though the name of the flag leaves something to desire,
since it doesn't just drop the PV for COW, but also for REGEXP and GLOB
arguments.

Tony

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=116925

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About