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

Improved performance of ViewNavigatorEntryIterator #161

Closed
4ndyc opened this issue May 16, 2017 · 2 comments
Closed

Improved performance of ViewNavigatorEntryIterator #161

4ndyc opened this issue May 16, 2017 · 2 comments

Comments

@4ndyc
Copy link

4ndyc commented May 16, 2017

Performance of the ViewNavigatorEntryIterator can be boosted by around 20% - 30% compared to the existing implementation by altering it to use ViewNavigator.getNext() rather than ViewNavigator.getNext(ViewEntry) - see http://linqed.eu/2017/05/12/convenience-at-a-cost-comparing-domino-java-apis-performance-oda-legacy-jna/. I've tested the following implementation, comments etc excluded for brevity:

public class ViewNavigatorEntryIterator implements Iterator<ViewEntry> {

	private transient ViewNavigator navigator_;
	private transient ViewEntry currentEntry_;
	private transient ViewEntry nextEntry_;
	
	public ViewNavigatorEntryIterator(ViewNavigator navigator) {
		navigator_ = navigator;
		nextEntry_ = navigator_.getFirst();
	}
	
	public boolean hasNext() {
		return nextEntry_ != null;
	}
	
	public ViewEntry next() {
		if (hasNext()) {
			currentEntry_ = nextEntry_;
			nextEntry_ = navigator_.getNext();
			return currentEntry_;
		} else {
			return null;
		}
	}

	public void remove() {
		// Not implemented
	}
	
}
@the-ntf
Copy link
Contributor

the-ntf commented May 17, 2017 via email

@4ndyc
Copy link
Author

4ndyc commented May 17, 2017

Although the results still stand, on further investigation ViewNavigator.getNext(ViewEntry) doesn't look like the culprit. The actual cause of the problem is the call to hasNext in the iterator's next method, which increases the number of API calls.

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

No branches or pull requests

3 participants