Skip to content

Commit 6ec390b

Browse files
committed
move some work to the initial setup - hopefully this improves window setup speed
1 parent 1a653e6 commit 6ec390b

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

src/main/java/org/htmlunit/javascript/JavaScriptEngine.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.htmlunit.corejs.javascript.Function;
4747
import org.htmlunit.corejs.javascript.FunctionObject;
4848
import org.htmlunit.corejs.javascript.JavaScriptException;
49+
import org.htmlunit.corejs.javascript.MemberBox;
4950
import org.htmlunit.corejs.javascript.NativeArray;
5051
import org.htmlunit.corejs.javascript.NativeArrayIterator;
5152
import org.htmlunit.corejs.javascript.NativeConsole;
@@ -608,24 +609,24 @@ private static void configureProperties(final ClassConfiguration config, final S
608609
if (propertyMap != null) {
609610
for (final Entry<String, PropertyInfo> propertyEntry : propertyMap.entrySet()) {
610611
final PropertyInfo info = propertyEntry.getValue();
611-
final Method readMethod = info.getReadMethod();
612-
final Method writeMethod = info.getWriteMethod();
613-
scriptable.defineProperty(propertyEntry.getKey(), null, readMethod, writeMethod, ScriptableObject.EMPTY);
612+
final MemberBox readMethod = info.getReadMethod();
613+
final MemberBox writeMethod = info.getWriteMethod();
614+
scriptable.defineProperty(propertyEntry.getKey(), readMethod, writeMethod, ScriptableObject.EMPTY);
614615
}
615616
}
616617
}
617618

618619
private static void configureStaticProperties(final ClassConfiguration config, final ScriptableObject scriptable) {
619620
final Map<String, PropertyInfo> staticPropertyMap = config.getStaticPropertyMap();
620621
if (staticPropertyMap != null) {
621-
for (final Entry<String, ClassConfiguration.PropertyInfo> propertyEntry : staticPropertyMap.entrySet()) {
622-
final String propertyName = propertyEntry.getKey();
623-
final Method readMethod = propertyEntry.getValue().getReadMethod();
624-
final Method writeMethod = propertyEntry.getValue().getWriteMethod();
625-
final int flag = ScriptableObject.EMPTY;
626-
627-
scriptable.defineProperty(propertyName, null, readMethod, writeMethod, flag);
628-
}
622+
// for (final Entry<String, ClassConfiguration.PropertyInfo> propertyEntry : staticPropertyMap.entrySet()) {
623+
// final String propertyName = propertyEntry.getKey();
624+
// final Method readMethod = propertyEntry.getValue().getReadMethod();
625+
// final Method writeMethod = propertyEntry.getValue().getWriteMethod();
626+
// final int flag = ScriptableObject.EMPTY;
627+
//
628+
// scriptable.defineProperty(propertyName, null, readMethod, writeMethod, flag);
629+
// }
629630
}
630631
}
631632

src/main/java/org/htmlunit/javascript/configuration/ClassConfiguration.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
import java.util.List;
2323
import java.util.Map;
2424

25+
import org.htmlunit.corejs.javascript.MemberBox;
2526
import org.htmlunit.corejs.javascript.ScriptableObject;
2627
import org.htmlunit.corejs.javascript.Symbol;
28+
import org.htmlunit.corejs.javascript.lc.type.TypeInfoFactory;
2729
import org.htmlunit.javascript.HtmlUnitScriptable;
2830

2931
/**
@@ -313,8 +315,8 @@ public String getClassName() {
313315
* methods that implement the get and set functions.
314316
*/
315317
public static class PropertyInfo {
316-
private final Method readMethod_;
317-
private final Method writeMethod_;
318+
private final MemberBox readMethod_;
319+
private final MemberBox writeMethod_;
318320

319321
/**
320322
* Constructor.
@@ -323,21 +325,30 @@ public static class PropertyInfo {
323325
* @param writeMethod the writeMethod
324326
*/
325327
public PropertyInfo(final Method readMethod, final Method writeMethod) {
326-
readMethod_ = readMethod;
327-
writeMethod_ = writeMethod;
328+
MemberBox getterBox = null;
329+
if (readMethod != null) {
330+
getterBox = new MemberBox(readMethod, TypeInfoFactory.GLOBAL);
331+
}
332+
readMethod_ = getterBox;
333+
334+
MemberBox setterBox = null;
335+
if (writeMethod != null) {
336+
setterBox = new MemberBox(writeMethod, TypeInfoFactory.GLOBAL);
337+
}
338+
writeMethod_ = setterBox;
328339
}
329340

330341
/**
331342
* @return the readMethod
332343
*/
333-
public Method getReadMethod() {
344+
public MemberBox getReadMethod() {
334345
return readMethod_;
335346
}
336347

337348
/**
338349
* @return the writeMethod
339350
*/
340-
public Method getWriteMethod() {
351+
public MemberBox getWriteMethod() {
341352
return writeMethod_;
342353
}
343354
}

0 commit comments

Comments
 (0)