in reply to ASP and Storable woes
After running a modified version of tye's code (below) I was able to further push the thawing time for my 17K elements hash to 0.15s. This and the time it takes to move memory from $Application gives me a decent 0.26s total, which is 10x better than going to the database and well enough for our expected site traffic.
One big and a respectful bow towards tye!
{ my( $quote7, $quote8, $zero, $one, %quote, %unquote ); BEGIN { $quote7= pack "C", 0x7e; # Any 7-bit char. $quote8= pack "C", 0x7f; # Any _other_ 7-bit char. $zero = pack "C", 0x00; $one = pack "C", 0x01; @quote{ $quote7, $quote8, $zero }= ( $quote7.$quote7, $quote7.$quote8, $quote7.$one ); %unquote= reverse %quote; } sub strip8 { my( $bin )= @_; $bin =~ s#([$quote7$quote8$zero])#$quote{$1}#go; return $bin; } sub restore8 { my( $str )= @_; $str =~ s#([$quote7$quote8].)#$unquote{$1}#gos; return $str; } }
|
|---|