Skip to content

Commit

Permalink
Generalize lookup_or_eval for ::Number
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Nov 29, 2019
1 parent e8f07df commit b591acc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/interpret.jl
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ function lookup_or_eval(@nospecialize(recurse), frame, @nospecialize(node))
return lookup_var(frame, node)
elseif isa(node, Symbol)
return getfield(moduleof(frame), node)
elseif isa(node, Int)
return node
elseif isa(node, QuoteNode)
return node.value
elseif isa(node, Expr)
Expand All @@ -105,6 +103,8 @@ function lookup_or_eval(@nospecialize(recurse), frame, @nospecialize(node))
dump(ex)
error("unknown expr ", ex)
end
elseif isa(node, Number) # slow, requires subtyping
return node
elseif isa(node, Type)
return node
end
Expand Down

3 comments on commit b591acc

@timholy
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh drat, meant to put this in a PR, not on master. Well, let's see what happens on CI...

@KristofferC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could keep the Int check if that one is the most common, which would then not require subtyping in the common case? Perhaps subtyping itself has some fast paths though?

@timholy
Copy link
Member Author

@timholy timholy commented on b591acc Dec 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in b633980. Performance probably isn't a big deal here, since this only affects toplevel (i.e., Revise) where there are no loops. But doesn't hurt.

Please sign in to comment.