Closed Bug 463867 Opened 17 years ago Closed 17 years ago

Superfluous code in ScriptableObject associateValue

Categories

(Rhino Graveyard :: Core, enhancement)

head
enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: petermichaux, Assigned: norrisboyd)

Details

Attachments

(1 file)

In ScriptableObject, the definition of associateValue is public synchronized final Object associateValue(Object key, Object value) { if (value == null) throw new IllegalArgumentException(); Map<Object,Object> h = associatedValues; if (h == null) { h = associatedValues; if (h == null) { h = new HashMap<Object,Object>(); associatedValues = h; } } return Kit.initHash(h, key, value); } This looks something like double check locking but without a synchronized check between the two tests for h being null. Since the whole method is synchronized, couldn't this code be reduced to public synchronized final Object associateValue(Object key, Object value) { if (value == null) throw new IllegalArgumentException(); Map<Object,Object> h = associatedValues; if (h == null) { h = new HashMap<Object,Object>(); associatedValues = h; } return Kit.initHash(h, key, value); }
Fixed: Checking in src/org/mozilla/javascript/ScriptableObject.java; /cvsroot/mozilla/js/rhino/src/org/mozilla/javascript/ScriptableObject.java,v <-- ScriptableObject.java new revision: 1.143; previous revision: 1.142 done
Assignee: nobody → norrisboyd
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: