Skip to content

Slight performance improvement for AePageObjects::Collection#each#191

Merged
tlconnor merged 1 commit intomasterfrom
collectionEachPerformanceImprovement
Sep 19, 2016
Merged

Slight performance improvement for AePageObjects::Collection#each#191
tlconnor merged 1 commit intomasterfrom
collectionEachPerformanceImprovement

Conversation

@tlconnor
Copy link
Copy Markdown

Currently AePageObjects::Collection#each uses #at(index) for each loop iteration. This means that the query to determine the collection size will be executed for each iteration of the loop.

This PR changes AePageObjects::Collection#each to instead use #item_at(index) which skips the unnecessary size check and reduces the total number of queries performed.

@@ -36,7 +36,7 @@ def [](index)

def each
(0..(size - 1)).each do |index|
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not completely related, but can this be size.times?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed

@tlconnor tlconnor force-pushed the collectionEachPerformanceImprovement branch from 2443432 to 044ce67 Compare September 19, 2016 21:12
@bboe
Copy link
Copy Markdown
Contributor

bboe commented Sep 19, 2016

👍

@tlconnor tlconnor merged commit e57f0be into master Sep 19, 2016
@tlconnor tlconnor deleted the collectionEachPerformanceImprovement branch September 19, 2016 22:48
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