Skip to content

Commit f7c8d1d

Browse files
committed
Fix cases where associative arrays should be created
This avoids the cost of converting a normal array to an associative array later.
1 parent acc201c commit f7c8d1d

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

src/main/java/com/laytonsmith/core/Static.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,7 @@ public String getString(CResource res) {
16151615
return getMSObject(((Collection) object).toArray(), t);
16161616
} else if(object instanceof Map) {
16171617
Map map = ((Map) object);
1618-
CArray r = new CArray(t);
1618+
CArray r = CArray.GetAssociativeArray(t);
16191619
for(Object key : map.keySet()) {
16201620
Object o = map.get(key);
16211621
r.set(key.toString(), (o == object) ? r : getMSObject(o, t), t);

src/main/java/com/laytonsmith/core/functions/Easings.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public Mixed exec(Target t, Environment env, Mixed... args) throws ConfigRuntime
149149
= ArgumentValidation.getEnum(args[2], com.laytonsmith.core.Easings.EasingType.class, t);
150150
double x = ArgumentValidation.getDouble(args[3], t);
151151
double percentage = com.laytonsmith.core.Easings.GetEasing(type, x);
152-
CArray result = new CArray(Target.UNKNOWN);
152+
CArray result = CArray.GetAssociativeArray(Target.UNKNOWN);
153153
result.set("x", startX + (finishX - startX) * percentage);
154154
result.set("y", startY + (finishY - startY) * percentage);
155155
result.set("z", startZ + (finishZ - startZ) * percentage);

src/main/java/com/laytonsmith/core/functions/EntityManagement.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -5246,25 +5246,25 @@ public static CArray GetArrayFromTransformation(MCTransformation tr) {
52465246
Quaternionf rightRotationT = tr.getRightRotation();
52475247
Vector3f scaleT = tr.getScale();
52485248
Vector3f translationT = tr.getTranslation();
5249-
CArray leftRotation = new CArray(t, 4);
5249+
CArray leftRotation = CArray.GetAssociativeArray(t);
52505250
leftRotation.set("w", leftRotationT.w);
52515251
leftRotation.set("x", leftRotationT.x);
52525252
leftRotation.set("y", leftRotationT.y);
52535253
leftRotation.set("z", leftRotationT.z);
5254-
CArray rightRotation = new CArray(t, 4);
5254+
CArray rightRotation = CArray.GetAssociativeArray(t);
52555255
rightRotation.set("w", rightRotationT.w);
52565256
rightRotation.set("x", rightRotationT.x);
52575257
rightRotation.set("y", rightRotationT.y);
52585258
rightRotation.set("z", rightRotationT.z);
5259-
CArray scale = new CArray(t, 3);
5259+
CArray scale = CArray.GetAssociativeArray(t);
52605260
scale.set("x", scaleT.x);
52615261
scale.set("y", scaleT.y);
52625262
scale.set("z", scaleT.z);
5263-
CArray translation = new CArray(t, 3);
5263+
CArray translation = CArray.GetAssociativeArray(t);
52645264
translation.set("x", translationT.x);
52655265
translation.set("y", translationT.y);
52665266
translation.set("z", translationT.z);
5267-
CArray transformation = new CArray(t, 4);
5267+
CArray transformation = CArray.GetAssociativeArray(t);
52685268
transformation.set("leftRotation", leftRotation, t);
52695269
transformation.set("rightRotation", rightRotation, t);
52705270
transformation.set("scale", scale, t);

src/main/java/com/laytonsmith/core/functions/Environment.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ public Mixed exec(Target t, com.laytonsmith.core.environments.Environment enviro
10611061
if(owner == null) {
10621062
return CNull.NULL;
10631063
}
1064-
CArray ret = new CArray(t);
1064+
CArray ret = CArray.GetAssociativeArray(t);
10651065
ret.set("name", owner.getName());
10661066
ret.set("uuid", owner.getUniqueID().toString());
10671067
MCPlayerProfile playerProfile = skull.getPlayerProfile();

src/main/java/com/laytonsmith/core/functions/Reflection.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ public Boolean runAsync() {
357357
@Override
358358
public Mixed exec(Target t, Environment environment, Mixed... args) throws ConfigRuntimeException {
359359
CClassType type = ArgumentValidation.getClassType(args[0], t);
360-
CArray ret = new CArray(t);
360+
CArray ret = CArray.GetAssociativeArray(t);
361361
ret.set("fqcn", type.getFQCN().getFQCN());
362362
ret.set("name", type.getFQCN().getSimpleName());
363363
ret.set("interfaces", new CArray(t, type.getTypeInterfaces(environment)), t);

0 commit comments

Comments
 (0)