Skip to content

Commit

Permalink
Fix segfaulting splice invocation on perls < 5.8.7
Browse files Browse the repository at this point in the history
It seems that older perls crash on attempts to splice-replace
a subscript of the array currently being splice()d. Get rid of
the splice entirely, and instead just do a reassignment.
Shouldn't make that much of a perf-difference.
  • Loading branch information
ribasushi committed Feb 12, 2012
1 parent f5fe6ed commit a981350
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Revision history for Perl extension Hash::MultiValue

- Fix segfaulting splice invocation on perls < 5.8.7
- Fix uninitialized warning on older perls

0.10 Sun Sep 18 12:51:49 PDT 2011
Expand Down
11 changes: 9 additions & 2 deletions lib/Hash/MultiValue.pm
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,15 @@ sub set {
}
push @keep, $i;
}
splice @$k, $start, 0+@$k, @$k[@keep];
splice @$v, $start, 0+@$v, @$v[@keep];

# this used to be written as
# splice @$_, $start, 0+@$_, @$_[@keep]
# however older perls crash on attempts to splice-replace a subscript
# of the array currently being splice()d
#
# I can not seem to find a relevant RT or perldelta entry, but this
# seems to have been fixed in 5.8.7
@$_ = @$_[0 .. $start-1, @keep] for ($k, $v);
}

if (@_) {
Expand Down

0 comments on commit a981350

Please sign in to comment.