Nil? takes much time


#1

Hello all.

In one my class I’ve had very simple method:


def stored?
!@db.nil?
end

And I’ve suddenly noticed (due to profile) that nil? Takes a significant
amount of time here.

Redefining the above method like

def stored?
@db
end

(in if’s it works good) speedups the entire program.

I’m a bit surprized :slight_smile:

Victor.