Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Slight code speedups #3

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

Merged
merged 1 commit into from
Dec 8, 2013
Merged

Slight code speedups #3

merged 1 commit into from
Dec 8, 2013

Conversation

johnmyleswhite
Copy link
Contributor

This PR makes the code a bit faster, although it also makes the code a bit uglier.

Basically, there are two types of changes:

  • Disable some bounds-checking using the @inbounds macro
  • Pull indexing operations out of loops when possible

Assert indexing operations are in bounds
Pull indexing operations out of loops when possible
end

function sampleCorpus(model::Model)
for ii in 1:length(model.corpus)
sampleDocument(ii, model)
end
return
Copy link
Owner

Choose a reason for hiding this comment

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

Are these just stylistic or do they impact performance in some way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question: they actually may not impact performance anymore. At one point in the past they could help the compiler from getting confused about the return type of for loops, but that doesn't seem to be true anymore.

slycoder pushed a commit that referenced this pull request Dec 8, 2013
@slycoder slycoder merged commit e1a242b into slycoder:master Dec 8, 2013
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