From: "Iñaki Baz Castillo" Date: 2009-04-02T18:28:28+09:00 Subject: Re: Symbols garbage collector in Ruby1.9, fixed? 2009/4/2 Michael Neumann : > I'd figure out what very common headers are and make them freezed constants, > like: > >  FROM = "From".freeze >  TO = "To".freeze > > and put references to those string "constants" as keys into the Hash. I > assume that this will be as fast as symbols when accessing the hash with > those constants, as equality testing just needs to tests for object identity > (object_id) and not for the equality of the content. > >  headers = {} >  headers[FROM] = "alice@qweeq" >  headers[TO] = "bob@qweqwe" Very interesting solution, but I would have some issues with it: a) I receive a request with various headers, most of them are well kwnown but others can be custom. When I extract the header name (after parsing) I get "From" and "Custom-Header" strings, and I need to check if these strings belongs to well known headers or not before storing them as FROM and "Custom-Header". Wouldn't this check be inneficient? b) Some wellk wnown headers have a name like "Record-Route". The "-" symbol is of course dissallowed as Ruby Constant. Using Symbols I can use it as :"record-route". Well, I have to think about it. Thanks a lot for all the received help. Regards. > Btw, this is the approach that for example Mongrel uses. Then I must investigate how it handles case b). -- Iñaki Baz Castillo