Skip to content

Commit 79dbd3c

Browse files
rbrigbrail
authored andcommitted
code cleanup
1 parent 0f617f9 commit 79dbd3c

1 file changed

Lines changed: 21 additions & 26 deletions

File tree

rhino/src/main/java/org/mozilla/javascript/IdScriptableObject.java

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ private static final class PrototypeValues implements Serializable {
3939
private Object[] valueArray;
4040
private short[] attributeArray;
4141

42-
// The following helps to avoid creation of valueArray during runtime
43-
// initialization for common case of "constructor" property
42+
// The following helps to avoid the creation of valueArray during runtime
43+
// initialization for the common case of "constructor" property
4444
int constructorId;
4545
private IdFunctionObject constructor;
4646
private short constructorAttrs;
4747

4848
PrototypeValues(IdScriptableObject obj, int maxId) {
49-
if (obj == null) throw new IllegalArgumentException();
50-
if (maxId < 1) throw new IllegalArgumentException();
49+
if (obj == null) throw new IllegalArgumentException("obj == null");
50+
if (maxId < 1) throw new IllegalArgumentException("maxId < 1");
5151
this.obj = obj;
5252
this.maxId = maxId;
5353
}
@@ -57,9 +57,10 @@ final int getMaxId() {
5757
}
5858

5959
final void initValue(int id, String name, Object value, int attributes) {
60-
if (!(1 <= id && id <= maxId)) throw new IllegalArgumentException();
61-
if (name == null) throw new IllegalArgumentException();
62-
if (value == NOT_FOUND) throw new IllegalArgumentException();
60+
if (!(1 <= id && id <= maxId))
61+
throw new IllegalArgumentException("!(1 <= id && id <= maxId)");
62+
if (name == null) throw new IllegalArgumentException("name == null");
63+
if (value == NOT_FOUND) throw new IllegalArgumentException("value == NOT_FOUND");
6364
ScriptableObject.checkValidAttributes(attributes);
6465
if (obj.findPrototypeId(name) != id) throw new IllegalArgumentException(name);
6566

@@ -77,9 +78,10 @@ final void initValue(int id, String name, Object value, int attributes) {
7778
}
7879

7980
final void initValue(int id, Symbol key, Object value, int attributes) {
80-
if (!(1 <= id && id <= maxId)) throw new IllegalArgumentException();
81-
if (key == null) throw new IllegalArgumentException();
82-
if (value == NOT_FOUND) throw new IllegalArgumentException();
81+
if (!(1 <= id && id <= maxId))
82+
throw new IllegalArgumentException("!(1 <= id && id <= maxId)");
83+
if (key == null) throw new IllegalArgumentException("key == null");
84+
if (value == NOT_FOUND) throw new IllegalArgumentException("value == NOT_FOUND");
8385
ScriptableObject.checkValidAttributes(attributes);
8486
if (obj.findPrototypeId(key) != id) throw new IllegalArgumentException(key.toString());
8587

@@ -167,7 +169,7 @@ final Object get(int id) {
167169
}
168170

169171
final void set(int id, Scriptable start, Object value) {
170-
if (value == NOT_FOUND) throw new IllegalArgumentException();
172+
if (value == NOT_FOUND) throw new IllegalArgumentException("value == NOT_FOUND");
171173
ensureId(id);
172174
int attr = attributeArray[id - 1];
173175
if ((attr & READONLY) == 0) {
@@ -680,7 +682,7 @@ protected Object getInstanceIdValue(int id) {
680682
}
681683

682684
/**
683-
* Set or delete id value. If value == NOT_FOUND , the implementation should make sure that the
685+
* Set or delete id value. If value == NOT_FOUND, the implementation should make sure that the
684686
* following getInstanceIdValue return NOT_FOUND.
685687
*/
686688
protected void setInstanceIdValue(int id, Object value) {
@@ -840,8 +842,7 @@ protected static <T> T ensureType(Object obj, Class<T> clazz, IdFunctionObject f
840842

841843
private IdFunctionObject newIdFunction(
842844
Object tag, int id, String name, int arity, Scriptable scope) {
843-
IdFunctionObject function = null;
844-
function = new IdFunctionObject(this, tag, id, name, arity, scope);
845+
IdFunctionObject function = new IdFunctionObject(this, tag, id, name, arity, scope);
845846

846847
if (isSealed()) {
847848
function.sealObject();
@@ -969,23 +970,20 @@ private ScriptableObject getBuiltInDataDescriptor(String name) {
969970
}
970971

971972
private Slot getBuiltInSlot(String name) {
972-
Object value = null;
973-
int attr = EMPTY;
974-
975973
int info = findInstanceIdInfo(name);
976974
if (info != 0) {
977975
int id = (info & 0xFFFF);
978-
value = getInstanceIdValue(id);
979-
attr = (info >>> 16);
976+
Object value = getInstanceIdValue(id);
977+
int attr = (info >>> 16);
980978
var slot = new Slot(name, 0, attr);
981979
slot.value = value;
982980
return slot;
983981
}
984982
if (prototypeValues != null) {
985983
int id = prototypeValues.findId(name);
986984
if (id != 0) {
987-
value = prototypeValues.get(id);
988-
attr = prototypeValues.getAttributes(id);
985+
Object value = prototypeValues.get(id);
986+
int attr = prototypeValues.getAttributes(id);
989987
var slot = new Slot(name, 0, attr);
990988
slot.value = value;
991989
return slot;
@@ -1005,14 +1003,11 @@ private ScriptableObject getBuiltInDataDescriptor(Symbol key) {
10051003
}
10061004

10071005
private Slot getBuiltInSlot(Symbol key) {
1008-
Object value = null;
1009-
int attr = EMPTY;
1010-
10111006
if (prototypeValues != null) {
10121007
int id = prototypeValues.findId(key);
10131008
if (id != 0) {
1014-
value = prototypeValues.get(id);
1015-
attr = prototypeValues.getAttributes(id);
1009+
Object value = prototypeValues.get(id);
1010+
int attr = prototypeValues.getAttributes(id);
10161011
var slot = new Slot(key, 0, attr);
10171012
slot.value = value;
10181013
return slot;

0 commit comments

Comments
 (0)