On Aug 24, 12:02 pm, Dave Howell <[email protected]>
wrote:
> I'm looking through some of the core Sequel code, and I found this little 
> thing:
>
>       def primary_key_lookup(pk)
>         if t = simple_table and p = simple_pk
>           with_sql("SELECT * FROM #{t} WHERE #{p} = 
> #{dataset.literal(pk)}").first
>         else
>           dataset[primary_key_hash(pk)]
>         end
>       end
>
> I don't understand why there are assignments to 't' and 'p'. Why doesn't this 
> method look like

Local variable access is cheaper than a method call.  So it's cheaper
to cache the result in a local variable than call the method twice.
It's a micro optimization.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to