Closed Bug 1317430 Opened 8 years ago Closed 8 years ago

Avoid a unnecessary copy by passing a const &

Categories

(Developer Infrastructure :: Source Code Analysis, defect)

51 Branch
defect
Not set
normal

Tracking

(firefox53 fixed)

RESOLVED FIXED
mozilla53
Tracking Status
firefox53 --- fixed

People

(Reporter: Sylvestre, Assigned: Sylvestre)

References

(Blocks 1 open bug)

Details

Attachments

(8 files)

No description provided.
Attachment #8810584 - Flags: review?(bugs)
Attachment #8810585 - Flags: review?(jyavenard)
Attachment #8810586 - Flags: review?(n.nethercote)
Attachment #8810587 - Flags: review?(nical.bugzilla)
Attachment #8810588 - Flags: review?(jwalden+bmo)
Attachment #8810589 - Flags: review?(mstange)
Attachment #8810590 - Flags: review?(valentin.gosu)
Attachment #8810591 - Flags: review?(n.nethercote)
Comment on attachment 8810591 [details] Bug 1317430 - Avoid a unnecessary copy by passing a const & in view/ https://reviewboard.mozilla.org/r/92880/#review93010
Attachment #8810591 - Flags: review?(n.nethercote) → review+
Comment on attachment 8810586 [details] Bug 1317430 - Avoid a unnecessary copy by passing a const & in extensions/spellcheck/ https://reviewboard.mozilla.org/r/92870/#review93012
Attachment #8810586 - Flags: review?(n.nethercote) → review+
Comment on attachment 8810587 [details] Bug 1317430 - Avoid a unnecessary copy by passing a const & in gfx/ https://reviewboard.mozilla.org/r/92872/#review93038 Does this help with reducing the static analysis / warnings noise? while it's preferable to pass objects with non-trivial destructors (like sk_sp) by const ref (or move) rather than value when possible, I don't think that passing Maybe<uint32_t> by reference brings any improvement (I am certain it won't make things noticeably worse either).
Attachment #8810587 - Flags: review?(nical.bugzilla) → review+
Comment on attachment 8810587 [details] Bug 1317430 - Avoid a unnecessary copy by passing a const & in gfx/ https://reviewboard.mozilla.org/r/92872/#review93038 This could help when passing large objects by value, that need to be copied on the stack of the calling function. There are some static analysis checkers that detect this and assert it as performance inneficient.
Comment on attachment 8810584 [details] Bug 1317430 - Avoid a unnecessary copy by passing a const & in dom/base/ https://reviewboard.mozilla.org/r/92794/#review93058
Attachment #8810584 - Flags: review?(bugs) → review+
Comment on attachment 8810585 [details] Bug 1317430 - Avoid a unnecessary copy by passing a const & in dom/media/ https://reviewboard.mozilla.org/r/92868/#review93052 ::: dom/media/MediaFormatReader.h:10 (Diff revision 1) > * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ > > #if !defined(MediaFormatReader_h_) > #define MediaFormatReader_h_ > > +#include <utility> Please don't use std::move, use mfbt Move instead ::: dom/media/MediaFormatReader.h:574 (Diff revision 1) > void OnVideoSeekFailed(const MediaResult& aError); > bool mSeekScheduled; > > void NotifyCompositorUpdated(RefPtr<layers::KnowsCompositor> aKnowsCompositor) > { > - mKnowsCompositor = aKnowsCompositor; > + mKnowsCompositor = std::move(aKnowsCompositor); aKnowsCompositor.forget() if you want remove the unecessary refcount increase ::: dom/media/MediaSegment.h:142 (Diff revision 1) > PrincipalHandle GetLastPrincipalHandle() const { return mLastPrincipalHandle; } > /** > * Called by the MediaStreamGraph as it appends a chunk with a different > * principal id than the current one. > */ > - void SetLastPrincipalHandle(PrincipalHandle aLastPrincipalHandle) > + void SetLastPrincipalHandle(const PrincipalHandle& aLastPrincipalHandle) I am not familiar with MediaSegment and PrincipalHandle I do not know how SetLastPrincipalHandle is called and if the passing by value wasn't intentional (it appears not but just in case.. Being a RefPtr, there's no much advantage being using a reference of the pointer by value. I let that being reviewed by its author. ::: dom/media/gmp/widevine-adapter/WidevineDecryptor.cpp:37 (Diff revision 1) > } > > void > WidevineDecryptor::SetCDM(RefPtr<CDMWrapper> aCDM) > { > - mCDM = aCDM; > + mCDM = std::move(aCDM); same as earlier. Use Move(), or better, aCDM.forget()
Attachment #8810585 - Flags: review?(jyavenard) → review+
Attachment #8810585 - Flags: review?(pehrson)
Comment on attachment 8810585 [details] Bug 1317430 - Avoid a unnecessary copy by passing a const & in dom/media/ https://reviewboard.mozilla.org/r/92868/#review93062
Attachment #8810585 - Flags: review?(pehrson) → review+
Comment on attachment 8810590 [details] Bug 1317430 - Avoid a unnecessary copy by passing a const & in netwerk/ https://reviewboard.mozilla.org/r/92878/#review93068
Attachment #8810590 - Flags: review?(valentin.gosu) → review+
Comment on attachment 8810589 [details] Bug 1317430 - Avoid a unnecessary copy by passing a const & in layout/ https://reviewboard.mozilla.org/r/92876/#review93116
Attachment #8810589 - Flags: review?(mstange) → review+
Comment on attachment 8810588 [details] Bug 1317430 - Avoid a unnecessary copy by passing a const & in js/ https://reviewboard.mozilla.org/r/92874/#review93186
Attachment #8810588 - Flags: review?(jwalden+bmo) → review+
Pushed by sledru@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2eaddb9f053a Avoid a unnecessary copy by passing a const & in dom/base/ r=smaug https://hg.mozilla.org/integration/autoland/rev/0d8fa19c7fa9 Avoid a unnecessary copy by passing a const & in extensions/spellcheck/ r=njn https://hg.mozilla.org/integration/autoland/rev/90f23af9f67b Avoid a unnecessary copy by passing a const & in gfx/ r=nical https://hg.mozilla.org/integration/autoland/rev/3e2bacaba546 Avoid a unnecessary copy by passing a const & in js/ r=Waldo https://hg.mozilla.org/integration/autoland/rev/8991ec245323 Avoid a unnecessary copy by passing a const & in netwerk/ r=valentin https://hg.mozilla.org/integration/autoland/rev/c6c5eee7d566 Avoid a unnecessary copy by passing a const & in view/ r=njn https://hg.mozilla.org/integration/autoland/rev/27b29b39a393 Avoid a unnecessary copy by passing a const & in dom/media/ r=jya,pehrsons https://hg.mozilla.org/integration/autoland/rev/3c5b4130f199 Avoid a unnecessary copy by passing a const & in layout/ r=mstange
Assignee: nobody → sledru
Product: Core → Firefox Build System
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: