Skip to content

Commit 5a422ba

Browse files
committed
[Fizz] Optimize end tags chunks (#27522)
Implements `endChunkForTag` to make writing end tags faster DiffTrain build for [8c85b02](8c85b02)
1 parent 293517d commit 5a422ba

9 files changed

+179
-164
lines changed

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
f172fa74610df623f1e82997ba66337452deeaa1
1+
8c85b02996b940d63f961f835348a0dd0045d3b6

compiled/facebook-www/ReactART-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
6969
return self;
7070
}
7171

72-
var ReactVersion = "18.3.0-www-modern-6d0bc8c7";
72+
var ReactVersion = "18.3.0-www-modern-f6a06001";
7373

7474
var LegacyRoot = 0;
7575
var ConcurrentRoot = 1;

compiled/facebook-www/ReactART-prod.modern.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9848,7 +9848,7 @@ var slice = Array.prototype.slice,
98489848
return null;
98499849
},
98509850
bundleType: 0,
9851-
version: "18.3.0-www-modern-75350665",
9851+
version: "18.3.0-www-modern-27dfd1a3",
98529852
rendererPackageName: "react-art"
98539853
};
98549854
var internals$jscomp$inline_1302 = {
@@ -9879,7 +9879,7 @@ var internals$jscomp$inline_1302 = {
98799879
scheduleRoot: null,
98809880
setRefreshHandler: null,
98819881
getCurrentFiber: null,
9882-
reconcilerVersion: "18.3.0-www-modern-75350665"
9882+
reconcilerVersion: "18.3.0-www-modern-27dfd1a3"
98839883
};
98849884
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
98859885
var hook$jscomp$inline_1303 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled/facebook-www/ReactDOMServer-dev.classic.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (__DEV__) {
1919
var React = require("react");
2020
var ReactDOM = require("react-dom");
2121

22-
var ReactVersion = "18.3.0-www-classic-89c1183f";
22+
var ReactVersion = "18.3.0-www-classic-3ac6c75e";
2323

2424
// This refers to a WWW module.
2525
var warningWWW = require("warning");
@@ -4167,7 +4167,7 @@ function pushStyleImpl(target, props) {
41674167
}
41684168

41694169
pushInnerHTML(target, innerHTML, children);
4170-
target.push(endTag1, stringToChunk("style"), endTag2);
4170+
target.push(endChunkForTag("style"));
41714171
return null;
41724172
}
41734173

@@ -4483,7 +4483,7 @@ function pushTitleImpl(target, props) {
44834483
}
44844484

44854485
pushInnerHTML(target, innerHTML, children);
4486-
target.push(endTag1, stringToChunk("title"), endTag2);
4486+
target.push(endChunkForTag("title"));
44874487
return null;
44884488
}
44894489

@@ -4656,7 +4656,7 @@ function pushScriptImpl(target, props) {
46564656
target.push(stringToChunk(encodeHTMLTextNode(children)));
46574657
}
46584658

4659-
target.push(endTag1, stringToChunk("script"), endTag2);
4659+
target.push(endChunkForTag("script"));
46604660
return null;
46614661
}
46624662

@@ -5080,8 +5080,19 @@ function pushStartInstance(
50805080

50815081
return pushStartGenericElement(target, props, type);
50825082
}
5083-
var endTag1 = stringToPrecomputedChunk("</");
5084-
var endTag2 = stringToPrecomputedChunk(">");
5083+
var endTagCache = new Map();
5084+
5085+
function endChunkForTag(tag) {
5086+
var chunk = endTagCache.get(tag);
5087+
5088+
if (chunk === undefined) {
5089+
chunk = stringToPrecomputedChunk("</" + tag + ">");
5090+
endTagCache.set(tag, chunk);
5091+
}
5092+
5093+
return chunk;
5094+
}
5095+
50855096
function pushEndInstance(target, type, props, resumableState, formatContext) {
50865097
switch (type) {
50875098
// When float is on we expect title and script tags to always be pushed in
@@ -5136,7 +5147,7 @@ function pushEndInstance(target, type, props, resumableState, formatContext) {
51365147
break;
51375148
}
51385149

5139-
target.push(endTag1, stringToChunk(type), endTag2);
5150+
target.push(endChunkForTag(type));
51405151
}
51415152

51425153
function writeBootstrap(destination, renderState) {
@@ -6052,9 +6063,7 @@ function writePreamble(
60526063
// if the main content contained the </head> it would also have provided a
60536064
// <head>. This means that all the content inside <html> is either <body> or
60546065
// invalid HTML
6055-
writeChunk(destination, endTag1);
6056-
writeChunk(destination, stringToChunk("head"));
6057-
writeChunk(destination, endTag2);
6066+
writeChunk(destination, endChunkForTag("head"));
60586067
}
60596068
} // We don't bother reporting backpressure at the moment because we expect to
60606069
// flush the entire preamble in a single pass. This probably should be modified
@@ -6111,15 +6120,11 @@ function writeHoistables(destination, resumableState, renderState) {
61116120
}
61126121
function writePostamble(destination, resumableState) {
61136122
if (resumableState.hasBody) {
6114-
writeChunk(destination, endTag1);
6115-
writeChunk(destination, stringToChunk("body"));
6116-
writeChunk(destination, endTag2);
6123+
writeChunk(destination, endChunkForTag("body"));
61176124
}
61186125

61196126
if (resumableState.hasHtml) {
6120-
writeChunk(destination, endTag1);
6121-
writeChunk(destination, stringToChunk("html"));
6122-
writeChunk(destination, endTag2);
6127+
writeChunk(destination, endChunkForTag("html"));
61236128
}
61246129
}
61256130
var arrayFirstOpenBracket = stringToPrecomputedChunk("[");

compiled/facebook-www/ReactDOMServer-dev.modern.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (__DEV__) {
1919
var React = require("react");
2020
var ReactDOM = require("react-dom");
2121

22-
var ReactVersion = "18.3.0-www-modern-6d0bc8c7";
22+
var ReactVersion = "18.3.0-www-modern-f6a06001";
2323

2424
// This refers to a WWW module.
2525
var warningWWW = require("warning");
@@ -4167,7 +4167,7 @@ function pushStyleImpl(target, props) {
41674167
}
41684168

41694169
pushInnerHTML(target, innerHTML, children);
4170-
target.push(endTag1, stringToChunk("style"), endTag2);
4170+
target.push(endChunkForTag("style"));
41714171
return null;
41724172
}
41734173

@@ -4483,7 +4483,7 @@ function pushTitleImpl(target, props) {
44834483
}
44844484

44854485
pushInnerHTML(target, innerHTML, children);
4486-
target.push(endTag1, stringToChunk("title"), endTag2);
4486+
target.push(endChunkForTag("title"));
44874487
return null;
44884488
}
44894489

@@ -4656,7 +4656,7 @@ function pushScriptImpl(target, props) {
46564656
target.push(stringToChunk(encodeHTMLTextNode(children)));
46574657
}
46584658

4659-
target.push(endTag1, stringToChunk("script"), endTag2);
4659+
target.push(endChunkForTag("script"));
46604660
return null;
46614661
}
46624662

@@ -5080,8 +5080,19 @@ function pushStartInstance(
50805080

50815081
return pushStartGenericElement(target, props, type);
50825082
}
5083-
var endTag1 = stringToPrecomputedChunk("</");
5084-
var endTag2 = stringToPrecomputedChunk(">");
5083+
var endTagCache = new Map();
5084+
5085+
function endChunkForTag(tag) {
5086+
var chunk = endTagCache.get(tag);
5087+
5088+
if (chunk === undefined) {
5089+
chunk = stringToPrecomputedChunk("</" + tag + ">");
5090+
endTagCache.set(tag, chunk);
5091+
}
5092+
5093+
return chunk;
5094+
}
5095+
50855096
function pushEndInstance(target, type, props, resumableState, formatContext) {
50865097
switch (type) {
50875098
// When float is on we expect title and script tags to always be pushed in
@@ -5136,7 +5147,7 @@ function pushEndInstance(target, type, props, resumableState, formatContext) {
51365147
break;
51375148
}
51385149

5139-
target.push(endTag1, stringToChunk(type), endTag2);
5150+
target.push(endChunkForTag(type));
51405151
}
51415152

51425153
function writeBootstrap(destination, renderState) {
@@ -6052,9 +6063,7 @@ function writePreamble(
60526063
// if the main content contained the </head> it would also have provided a
60536064
// <head>. This means that all the content inside <html> is either <body> or
60546065
// invalid HTML
6055-
writeChunk(destination, endTag1);
6056-
writeChunk(destination, stringToChunk("head"));
6057-
writeChunk(destination, endTag2);
6066+
writeChunk(destination, endChunkForTag("head"));
60586067
}
60596068
} // We don't bother reporting backpressure at the moment because we expect to
60606069
// flush the entire preamble in a single pass. This probably should be modified
@@ -6111,15 +6120,11 @@ function writeHoistables(destination, resumableState, renderState) {
61116120
}
61126121
function writePostamble(destination, resumableState) {
61136122
if (resumableState.hasBody) {
6114-
writeChunk(destination, endTag1);
6115-
writeChunk(destination, stringToChunk("body"));
6116-
writeChunk(destination, endTag2);
6123+
writeChunk(destination, endChunkForTag("body"));
61176124
}
61186125

61196126
if (resumableState.hasHtml) {
6120-
writeChunk(destination, endTag1);
6121-
writeChunk(destination, stringToChunk("html"));
6122-
writeChunk(destination, endTag2);
6127+
writeChunk(destination, endChunkForTag("html"));
61236128
}
61246129
}
61256130
var arrayFirstOpenBracket = stringToPrecomputedChunk("[");

0 commit comments

Comments
 (0)