# N-hashes code adapted from docs to Class::Std sub BUILD { my ($self, $obj_ID, $arg_ref) = @_; $name{$obj_ID} = $arg_ref->{name} || $default_of{name}; $rank{$obj_ID} = $arg_ref->{rank} || $default_of{rank}; # repeat for N properties } # HoH way sub BUILD { my ($self, $obj_ID, $arg_ref) = @_; $data{$obj_ID} = { %default_of, %$arg_ref }; } #### sub CLONE { # fix-up all object ids in the new thread for my $old_id ( keys %REGISTRY ) { # look under old_id to find the new, cloned reference my $object = $REGISTRY{ $old_id }; my $new_id = refaddr $object; # relocate data $NAME{ $new_id } = $NAME{ $old_id }; delete $NAME{ $old_id }; # repeat relocation for N properties # update the weak reference to the new, cloned object weaken ( $REGISTRY{ $new_id } = $REGISTRY{ $old_id } ); delete $REGISTRY{ $old_id }; } return; } #### Rate NHashObject HoHObject NHashObject 51694/s -- -43% HoHObject 90761/s 76% -- #### Rate NHashObject HoHObject NHashObject 50557/s -- -4% HoHObject 52932/s 5% -- #### Rate HoHObject NHashObject HoHObject 60857/s -- -4% NHashObject 63625/s 5% --