On 1 Jul 2009, at 06:57, Brian Candler wrote:
> Robert Klemme wrote:
>>>  s.upcase
>>
>> You can probably squeeze out a bit performance especially for large
>> strings by replacing this with "s.upcase!; s".
>
> A very bad idea IMO. Why make your code larger and less readable for  
> the
> sake of perhaps one microsecond or less? If performance matters on  
> this
> microscopic scale, you should be writing in C.


I agree that "s.upcase!; s" is ugly, and I really wish the bang  
methods returned self on success and raised an exception on error as  
that's closer to how I use them than the current approach, but it's  
still a well-established idiom and hardly likely to confuse even a  
neophyte so long as they bother to RTFM.

As to the notion that we should only write performant code in C... why  
complicate a codebase by using two languages (with all the debugging  
nightmare that can entail) if the language you're already working in  
is capable of doing the job anyway?


Ellie

Eleanor McHugh
Games With Brains
http://slides.games-with-brains.net
----
raise ArgumentError unless @reality.responds_to? :reason