Skip to content

Commit

Permalink
Save a get operation in ScriptEntry#getNext() - this seems to be the …
Browse files Browse the repository at this point in the history
…bottleneck for Denizen, so perhaps could look into using a Queue or entry head index in the future
  • Loading branch information
fullwall committed Dec 16, 2013
1 parent 7f7829e commit 1e05cf3
Showing 1 changed file with 1 addition and 3 deletions.
Expand Up @@ -503,9 +503,7 @@ protected void revolve() {

public ScriptEntry getNext() {
if (!script_entries.isEmpty()) {
ScriptEntry entry = script_entries.get(0);
script_entries.remove(0);
return entry;
return script_entries.remove(0);
}
else return null;
}
Expand Down

3 comments on commit 1e05cf3

@aufdemrand
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting. I've known there is some kind of bottleneck in that process. Can't wait to see the difference in /testload

@aufdemrand
Copy link
Contributor

Choose a reason for hiding this comment

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

Also, how would your two suggestions work?

@fullwall
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently script_entries is read left-to-right and entries are removed from the beginning of the list. This is more costly as the rest of the entries are shifted to the left. If you could rework the code to remove from the end of the list or avoid the .remove(0) call you can save that processing. (note that it was the bottleneck in a microbenchmark from mcmonkey)

Please sign in to comment.