Skip to content

Prefer addAll instead of iteration for performance#17248

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
nroduit:java-addall
May 14, 2020
Merged

Prefer addAll instead of iteration for performance#17248
opencv-pushbot merged 1 commit intoopencv:3.4from
nroduit:java-addall

Conversation

@nroduit
Copy link
Copy Markdown
Contributor

@nroduit nroduit commented May 9, 2020

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under OpenCV (BSD) License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Using addAll is preferred for performance reason (implementation of addAll uses System. arraycopy())

See https://dev.to/sendilkumarn/9-tips-to-increase-your-java-performance-1l4d

if (lCount > 0) {
for (MatOfDMatch vdm : lvdm)
mats.add(vdm);
mats.addAll(kps);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

typo? lvdm

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes I publish a fix.

@asmorkalov asmorkalov added category: java bindings pr: needs rebase Rebase patch (and squash fixup commits) on the top of target branch labels May 12, 2020
@asmorkalov
Copy link
Copy Markdown
Contributor

Thanks for the contribution. The patch should go into 3.4 branch first. We will merge changes from 3.4 into master regularly (weekly/bi-weekly).

So, please:

  • change "base" branch of this PR: master => 3.4 (use "Edit" button near PR title)
  • rebase your commits from master onto 3.4 branch. For example:
    git rebase -i --onto upstream/3.4 upstream/master
    (check list of your commits, save and quit (Esc + "wq" + Enter)
    where upstream is configured by following this GitHub guide and fetched (git fetch upstream).
  • push rebased commits into source branch of your fork (with --force option)

Note: no need to re-open PR, apply changes "inplace".

@asmorkalov asmorkalov changed the base branch from master to 3.4 May 14, 2020 08:44
@asmorkalov asmorkalov removed the pr: needs rebase Rebase patch (and squash fixup commits) on the top of target branch label May 14, 2020
@asmorkalov
Copy link
Copy Markdown
Contributor

@nroduit I squashed the commits and rebased the patch to 3.4.
@alalek The patch is ready, please merge.

@asmorkalov asmorkalov self-requested a review May 14, 2020 08:45
Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov left a comment

Choose a reason for hiding this comment

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

👍

@asmorkalov asmorkalov self-assigned this May 14, 2020
@opencv-pushbot opencv-pushbot merged commit ea3c230 into opencv:3.4 May 14, 2020
@alalek alalek mentioned this pull request May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants