Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix type instability in nextprod #15289

Merged
merged 1 commit into from
Mar 1, 2016
Merged

Fix type instability in nextprod #15289

merged 1 commit into from
Mar 1, 2016

Conversation

timholy
Copy link
Member

@timholy timholy commented Feb 29, 2016

Leads to a ~10% speedup.

@@ -196,8 +196,8 @@ function nextprod(a::Vector{Int}, x)
end
end
end
best = mx[end] < best ? mx[end] : best
return Int(best) # could overflow, but best to have predictable return type
best = mx[end] < best ? typeof(best)(mx[end]) : best
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be oftype(best, mx[end]).

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed.

timholy added a commit that referenced this pull request Mar 1, 2016
Fix type instability in nextprod
@timholy timholy merged commit 42608a8 into master Mar 1, 2016
@timholy timholy deleted the teh/nextprod branch March 1, 2016 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants