garu / Clone

recursively copy Perl datatypes
7 stars 10 forks source link

Reuse a Cowed PV when cloning #7

Closed atoomic closed 5 years ago

atoomic commented 7 years ago

RT 97535

atoomic commented 7 years ago
> perl -Iblib/lib -Iblib/arch -MClone=clone -MDevel::Peek -e 'my $x = q[ a ]; my $y = $x; print Dump $x; print Dump $y; my $z = { $y => $y }; print Dump clone  $z; print Dump $y'
SV = PV(0x7fe031005460) at 0x7fe03102cd70
  REFCNT = 1
  FLAGS = (POK,IsCOW,pPOK)
  PV = 0x7fe030c13ea0 " a "\0
  CUR = 3
  LEN = 10
  COW_REFCNT = 2
SV = PV(0x7fe031005560) at 0x7fe03102ccb0
  REFCNT = 1
  FLAGS = (POK,IsCOW,pPOK)
  PV = 0x7fe030c13ea0 " a "\0
  CUR = 3
  LEN = 10
  COW_REFCNT = 2
SV = IV(0x7fe0310282c8) at 0x7fe0310282d8
  REFCNT = 1
  FLAGS = (TEMP,ROK)
  RV = 0x7fe031028308
  SV = PVHV(0x7fe03100a060) at 0x7fe031028308
    REFCNT = 1
    FLAGS = (SHAREKEYS)
    ARRAY = 0x7fe030c0efb0  (0:7, 1:1)
    hash quality = 100.0%
    KEYS = 1
    FILL = 1
    MAX = 7
    Elt " a " HASH = 0xc098ed1b
    SV = PV(0x7fe0310055f0) at 0x7fe031028398
      REFCNT = 1
      FLAGS = (POK,IsCOW,pPOK)
      PV = 0x7fe030c13ea0 " a "\0
      CUR = 3
      LEN = 10
      COW_REFCNT = 4
SV = PV(0x7fe031005560) at 0x7fe03102ccb0
  REFCNT = 1
  FLAGS = (POK,IsCOW,pPOK)
  PV = 0x7fe030c13ea0 " a "\0
  CUR = 3
  LEN = 10
  COW_REFCNT = 3
coveralls commented 7 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 4435df7edb07a6ac2084af5f4eda24a128d968b0 on atoomic:devel/cow into 7266910b7c8def8afe48142d36bd21f6ac2258dc on garu:master.

toddr commented 7 years ago

This patch looks right to me!

atoomic commented 7 years ago

as discussed we are going to:

oalders commented 5 years ago

@garu what's the status on getting this merged?We are looking at optimizing our $work code for speed and this patch might be of help to us. I know that you are very busy right now. If you need any help with this, I can see about getting some $work time allotted to helping get this out the door.

atoomic commented 5 years ago

@garu I left this one behind, but IMO this one is now ready for a second review round and hopefully a release?

garu commented 5 years ago

Hey @atoomic @toddr @oalders, thank you for being so patient. Clone 0.40 is shipped! Please test and let me know if you bump into any issues \o/