From: khaines@... Date: 2007-12-30T15:27:31+09:00 Subject: Re: multibyte strings & bucket-of-bytes efficiency under 1.9.0 On Sat, 29 Dec 2007, murphy wrote: > I'm not sure if we need it...but it's more OO and looks nice. > how would we use it though? you don't declare variables in Ruby. Strings > are mostly generated by I/O methods (I guess File.open does return a > byte string if you read binary) and via literals (which have the default > encoding). no place for ByteString.new. def initialize @logchunk = ByteString.new end def receive_data(data) @logchunk << data # stuff.... msg = @logchunk.slice!(0..@length] # more stuff... end I'd use it something like that. > but force_encoding(nil) seems a bit ugly as a general pattern for binary > mode string handling. a String#binary proxy would be nice: And in my tests, it didn't solve the problem with abysmal slice! performance. Kirk Haines