Closed Bug 891695 Opened 12 years ago Closed 12 years ago

Don't pass pointers by const reference

Categories

(Core :: JavaScript Engine, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla25

People

(Reporter: sunfish, Assigned: sunfish)

Details

Attachments

(1 file)

Attached patch a proposed fixSplinter Review
MDefinition's congruentTo and a few other things pass pointers by const reference, e.g.: virtual bool congruentTo(MDefinition* const &ins) const Pointers are always cheap enough to pass by value, and it's simpler and more idiomatic to do so.
Attachment #773057 - Flags: review?(rpearl)
Comment on attachment 773057 [details] [diff] [review] a proposed fix Review of attachment 773057 [details] [diff] [review]: ----------------------------------------------------------------- This looks completely reasonable (although I haven't looked at Mozilla code in about a year now...)
Attachment #773057 - Flags: review?(rpearl) → review+
Ah, sorry for the trouble then. Thanks for the review! :) https://hg.mozilla.org/integration/mozilla-inbound/rev/1372b813d76f
(In reply to Carsten Book [:Tomcat] from comment #4) > and relanding on inbound > https://hg.mozilla.org/integration/mozilla-inbound/rev/56423bbe9a13 Not sure why as this still causes the same debug bustage it did last night. Backed out again. https://hg.mozilla.org/integration/mozilla-inbound/rev/15e6d2cab9f3
Comment on attachment 773057 [details] [diff] [review] a proposed fix Review of attachment 773057 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/jsapi.h @@ +2563,3 @@ > { > JSObject *updated = key; > JS_SET_TRACING_LOCATION(trc, reinterpret_cast<void *>(&const_cast<JSObject *&>(key))); This one looks wrong
Assignee: general → sunfish
Comment on attachment 773057 [details] [diff] [review] a proposed fix Review of attachment 773057 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/jsapi.h @@ +2563,3 @@ > { > JSObject *updated = key; > JS_SET_TRACING_LOCATION(trc, reinterpret_cast<void *>(&const_cast<JSObject *&>(key))); Good catch Ms2ger! Yes, this is wrong: we need to take the (correct) address of key to update the pointer. Normally we pass these by double-pointer to make it clear, hopefully avoiding this easy-to-make mistake. This case is a bit weird because |key| is embedded const in the HashMap: we don't want to force every user to const-cast it manully.
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla25
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: