From: Phrogz Date: 2009-11-01T02:00:11+09:00 Subject: Re: How do you get the tail end of a string? On Oct 30, 11:54 pm, Rajinder Yadav wrote: > Phrogz wrote: > > On Oct 30, 10:40 am, Bertram Scharpf wrote: > >> Your calculation needs more than four times as much processor > >> time. Don't you need to save time? > > > Really? You're arguing about the efficiency of something that is about > > 6.8µs slower? > > You took that personally, really? Of course not. My point was that too often people get focused on premature optimization. Just because one method is "four times" slower than another does not mean that one should necessarily be chosen over the other. My rule of thumb is: 1) Choose the right algorithms. 2) Choose the implementation most convenient for me. 3) If speed is an issue, benchmark your program and optimize the most painful parts first. Bertram's argument and implementation are only important, I'm saying, to someone who has written a program that needs to process millions of tail endings of strings in a time-critical application, and who has proven that the speed of String#[] is a significant portion of that time. (Important only to them, but perhaps interesting to more.)