Skip to content

Commit

Permalink
No need to conditionally check if it exists since we know it'll exist
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage committed Nov 21, 2022
1 parent c648fcd commit c736478
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions packages/react-server/src/ReactServerStreamConfigBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function writeChunk(

if (chunk.length > VIEW_SIZE) {
if (__DEV__) {
if (precomputedChunkSet && precomputedChunkSet.has(chunk)) {
if (precomputedChunkSet.has(chunk)) {
console.error(
'A large precomputed chunk was passed to writeChunk without being copied.' +
' Large chunks get enqueued directly and are not copied. This is incompatible with precomputed chunks because you cannot enqueue the same precomputed chunk twice.' +
Expand Down Expand Up @@ -126,15 +126,13 @@ export function stringToChunk(content: string): Chunk {
return textEncoder.encode(content);
}

const precomputedChunkSet = __DEV__ ? new Set() : null;
const precomputedChunkSet: Set<Chunk> = __DEV__ ? new Set() : (null: any);

export function stringToPrecomputedChunk(content: string): PrecomputedChunk {
const precomputedChunk = textEncoder.encode(content);

if (__DEV__) {
if (precomputedChunkSet) {
precomputedChunkSet.add(precomputedChunk);
}
precomputedChunkSet.add(precomputedChunk);
}

return precomputedChunk;
Expand Down

0 comments on commit c736478

Please sign in to comment.