Skip to content

Commit f1c0313

Browse files
Inline options._skipEffects
1 parent d1b9859 commit f1c0313

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const SHALLOW = { shallow: true };
1414

1515
// components without names, kept as a hash for later comparison to return consistent UnnamedComponentXX names.
1616
const UNNAMED = [];
17-
const _skipEffects = '__s';
1817

1918
const VOID_ELEMENTS = /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/;
2019

@@ -49,14 +48,20 @@ function renderToString(vnode, context, opts) {
4948
context = context || {};
5049
opts = opts || {};
5150

52-
const previousSkipEffects = options[_skipEffects];
53-
options[_skipEffects] = true;
51+
// Performance optimization: `renderToString` is synchronous and we
52+
// therefore don't execute any effects. To do that we pass an empty
53+
// array to `options._commit` (`__c`). But we can go one step further
54+
// and avoid a lot of dirty checks and allocations by setting
55+
// `options._skipEffects` (`__s`) too.
56+
const previousSkipEffects = options.__s;
57+
options.__s = true;
5458

5559
const res = _renderToString(vnode, context, opts);
60+
5661
// options._commit, we don't schedule any effects in this library right now,
5762
// so we can pass an empty queue to this hook.
5863
if (options.__c) options.__c(vnode, EMPTY_ARR);
59-
options[_skipEffects] = previousSkipEffects;
64+
options.__s = previousSkipEffects;
6065
return res;
6166
}
6267

0 commit comments

Comments
 (0)