Skip to content

Commit fabd57c

Browse files
committed
optimization - replace some language version checks with constant values
1 parent c0ba1bf commit fabd57c

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

build.gradle

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ apply plugin: 'signing'
1111

1212
group = "org.htmlunit"
1313
archivesBaseName = "htmlunit-core-js"
14-
version = "3.2.0"
14+
version = "3.3.0-SNAPSHOT"
1515

1616

1717
jar {
@@ -68,6 +68,49 @@ task generateSources() {
6868
}
6969
filter { line -> line.replaceAll('org\\.mozilla', 'org.htmlunit.corejs') }
7070
filter { line -> line.replaceAll('org/mozilla', 'org/htmlunit/corejs') }
71+
72+
// filter { line -> line.replaceAll('public static final int VERSION_', '// HtmlUnit public static final int VERSION_') }
73+
74+
filter { line -> line.replaceAll('version == Context.VERSION_1_0', '/* HtmlUnit version == #Context.VERSION_1_0 */ false') }
75+
filter { line -> line.replaceAll('version == Context.VERSION_1_1', '/* HtmlUnit version == #Context.VERSION_1_1 */ false') }
76+
filter { line -> line.replaceAll('version == Context.VERSION_1_2', '/* HtmlUnit version == #Context.VERSION_1_2 */ false') }
77+
filter { line -> line.replaceAll('version <= Context.VERSION_1_3', '/* HtmlUnit version <= #Context.VERSION_1_3 */ false') }
78+
filter { line -> line.replaceAll('version < Context.VERSION_1_3', '/* HtmlUnit version < #Context.VERSION_1_3 */ false') }
79+
filter { line -> line.replaceAll('version <= Context.VERSION_1_4', '/* HtmlUnit version <= #Context.VERSION_1_4 */ false') }
80+
filter { line -> line.replaceAll('version >= Context.VERSION_1_4', '/* HtmlUnit version >= #Context.VERSION_1_4 */ true') }
81+
filter { line -> line.replaceAll('version >= Context.VERSION_1_6', '/* HtmlUnit version >= #Context.VERSION_1_6 */ true') }
82+
filter { line -> line.replaceAll('cx.version < Context.VERSION_ES6', '/* HtmlUnit cx.version < #Context.VERSION_ES6 */ false') }
83+
filter { line -> line.replaceAll('version < Context.VERSION_ES6', '/* HtmlUnit version < #Context.VERSION_ES6 */ false') }
84+
85+
filter { line -> line.replaceAll('version == Context.VERSION_DEFAULT', '/* HtmlUnit version == #Context.VERSION_DEFAULT */ false') }
86+
filter { line -> line.replaceAll('version != Context.VERSION_DEFAULT', '/* HtmlUnit version != #Context.VERSION_DEFAULT */ true') }
87+
filter { line -> line.replaceAll('version == VERSION_DEFAULT \\|\\| version >= VERSION_1_3', '/* HtmlUnit version == #VERSION_DEFAULT \\|\\| version >= #VERSION_1_3 */ true') }
88+
89+
filter { line -> line.replaceAll('languageVersion < Context.VERSION_ES6', '/* HtmlUnit languageVersion < #Context.VERSION_ES6 */ false') }
90+
91+
filter { line -> line.replaceAll('cx.getLanguageVersion\\(\\) == Context.VERSION_1_2', '/* HtmlUnit cx.getLanguageVersion\\(\\) == #Context.VERSION_1_2 */ false') }
92+
filter { line -> line.replaceAll('cx.getLanguageVersion\\(\\) != Context.VERSION_1_2', '/* HtmlUnit cx.getLanguageVersion\\(\\) != #Context.VERSION_1_2 */ true') }
93+
filter { line -> line.replaceAll('getLanguageVersion\\(\\) != Context.VERSION_1_2', '/* HtmlUnit getLanguageVersion\\(\\) != #Context.VERSION_1_2 */ true') }
94+
filter { line -> line.replaceAll('state.cx.getLanguageVersion\\(\\) >= Context.VERSION_ES6', '/* HtmlUnit state.cx.getLanguageVersion\\(\\) >= #Context.VERSION_ES6 */ true') }
95+
filter { line -> line.replaceAll('cx.getLanguageVersion\\(\\) >= Context.VERSION_ES6', '/* HtmlUnit cx.getLanguageVersion\\(\\) >= #Context.VERSION_ES6 */ true') }
96+
filter { line -> line.replaceAll('cx.getLanguageVersion\\(\\) < Context.VERSION_ES6', '/* HtmlUnit cx.getLanguageVersion\\(\\) < #Context.VERSION_ES6 */ false') }
97+
filter { line -> line.replaceAll('cx.getLanguageVersion\\(\\) < Context.VERSION_1_5', '/* HtmlUnit cx.getLanguageVersion\\(\\) < #Context.VERSION_1_5 */ false') }
98+
filter { line -> line.replaceAll('cx.getLanguageVersion\\(\\) < Context.VERSION_1_6', '/* HtmlUnit cx.getLanguageVersion\\(\\) < #Context.VERSION_1_6 */ false') }
99+
filter { line -> line.replaceAll('cx.getLanguageVersion\\(\\) <= Context.VERSION_1_7', '/* HtmlUnit cx.getLanguageVersion\\(\\) < #Context.VERSION_1_7 */ false') }
100+
filter { line -> line.replaceAll('cx.getLanguageVersion\\(\\) >= Context.VERSION_1_8', '/* HtmlUnit cx.getLanguageVersion\\(\\) >= #Context.VERSION_1_8 */ true') }
101+
filter { line -> line.replaceAll('env.getLanguageVersion\\(\\) >= Context.VERSION_ES6', '/* HtmlUnit env.getLanguageVersion\\(\\) >= #Context.VERSION_ES6 */ true') }
102+
103+
filter { line -> line.replaceAll('Context.getCurrentContext\\(\\).version >= Context.VERSION_ES6', '/* HtmlUnit Context.getCurrentContext\\(\\).version >= #Context.VERSION_ES6 */ true') }
104+
filter { line -> line.replaceAll('Context.getCurrentContext\\(\\).getLanguageVersion\\(\\) >= Context.VERSION_ES6', '/* HtmlUnit Context.getCurrentContext\\(\\).getLanguageVersion\\(\\) >= #Context.VERSION_ES6 */ true') }
105+
filter { line -> line.replaceAll('Context.getContext\\(\\).getLanguageVersion\\(\\) < Context.VERSION_ES6', '/* HtmlUnit Context.getContext\\(\\).getLanguageVersion\\(\\) < #Context.VERSION_ES6 */ false') }
106+
107+
filter { line -> line.replaceAll('compilerEnv.getLanguageVersion\\(\\) == Context.VERSION_1_2', '/* HtmlUnit compilerEnv.getLanguageVersion\\(\\) == #Context.VERSION_1_2 */ false') }
108+
filter { line -> line.replaceAll('compilerEnv.getLanguageVersion\\(\\) < Context.VERSION_1_8', '/* HtmlUnit compilerEnv.getLanguageVersion\\(\\) < #Context.VERSION_1_8 */ false') }
109+
filter { line -> line.replaceAll('compilerEnv.getLanguageVersion\\(\\) >= Context.VERSION_1_8', '/* HtmlUnit compilerEnv.getLanguageVersion\\(\\) >= #Context.VERSION_1_8 */ true') }
110+
filter { line -> line.replaceAll('parser.compilerEnv.getLanguageVersion\\(\\) >= Context.VERSION_ES6', '/* HtmlUnit parser.compilerEnv.getLanguageVersion\\(\\) >= #Context.VERSION_ES6 */ true') }
111+
filter { line -> line.replaceAll('parser.compilerEnv.getLanguageVersion\\(\\) < Context.VERSION_1_7', '/* HtmlUnit parser.compilerEnv.getLanguageVersion\\(\\) < #Context.VERSION_1_7 */ false') }
112+
filter { line -> line.replaceAll('compilerEnv.getLanguageVersion\\(\\) >= Context.VERSION_ES6', '/* HtmlUnit compilerEnv.getLanguageVersion\\(\\) >= #Context.VERSION_ES6 */ true') }
113+
filter { line -> line.replaceAll('compilerEnv.getLanguageVersion\\(\\) < Context.VERSION_ES6', '/* HtmlUnit compilerEnv.getLanguageVersion\\(\\) < #Context.VERSION_ES6 */ false') }
71114
}
72115

73116
delete('target/rhinoDiff.txt')

0 commit comments

Comments
 (0)