GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Remove wasteful checks from `shouldYield` · react/react@9abc278

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • react/src/__tests__
      • ReactProfiler-test.internal.js
    • scheduler/src
      • Scheduler.js
      • __tests__
        • Scheduler-test.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/react/src/__tests__/ReactProfiler-test.internal.js‎

Copy file name to clipboardExpand all lines: packages/react/src/__tests__/ReactProfiler-test.internal.js
+3-7Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,15 +2481,11 @@ describe('Profiler', () => {
24812481
// Errors that happen inside of a subscriber should throw,
24822482
throwInOnWorkStarted = true;
24832483
expect(Scheduler).toFlushAndThrow('Expected error onWorkStarted');
2484-
// Rendering was interrupted by the error that was thrown
2485-
expect(Scheduler).toHaveYielded([]);
2486-
// Rendering continues in the next task
2487-
expect(Scheduler).toFlushAndYield(['Component:text']);
24882484
throwInOnWorkStarted = false;
2485+
// Rendering was interrupted by the error that was thrown, then
2486+
// continued and finished in the next task.
2487+
expect(Scheduler).toHaveYielded(['Component:text']);
24892488
expect(onWorkStarted).toHaveBeenCalled();
2490-
2491-
// But the React work should have still been processed.
2492-
expect(Scheduler).toFlushAndYield([]);
24932489
const tree = renderer.toTree();
24942490
expect(tree.type).toBe(Component);
24952491
expect(tree.props.children).toBe('text');
Collapse file

‎packages/scheduler/src/Scheduler.js‎

Copy file name to clipboardExpand all lines: packages/scheduler/src/Scheduler.js
+1-16Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -393,21 +393,6 @@ function unstable_getCurrentPriorityLevel() {
393393
return currentPriorityLevel;
394394
}
395395

396-
function unstable_shouldYield() {
397-
const currentTime = getCurrentTime();
398-
advanceTimers(currentTime);
399-
const firstTask = peek(taskQueue);
400-
return (
401-
(firstTask !== currentTask &&
402-
currentTask !== null &&
403-
firstTask !== null &&
404-
firstTask.callback !== null &&
405-
firstTask.startTime <= currentTime &&
406-
firstTask.expirationTime < currentTask.expirationTime) ||
407-
shouldYieldToHost()
408-
);
409-
}
410-
411396
const unstable_requestPaint = requestPaint;
412397

413398
export {
@@ -422,7 +407,7 @@ export {
422407
unstable_cancelCallback,
423408
unstable_wrapCallback,
424409
unstable_getCurrentPriorityLevel,
425-
unstable_shouldYield,
410+
shouldYieldToHost as unstable_shouldYield,
426411
unstable_requestPaint,
427412
unstable_continueExecution,
428413
unstable_pauseExecution,
Collapse file

‎packages/scheduler/src/__tests__/Scheduler-test.js‎

Copy file name to clipboardExpand all lines: packages/scheduler/src/__tests__/Scheduler-test.js
+6-7Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ describe('Scheduler', () => {
249249
});
250250

251251
it(
252-
'continuations are interrupted by higher priority work scheduled ' +
252+
'continuations do not block higher priority work scheduled ' +
253253
'inside an executing callback',
254254
() => {
255255
const tasks = [
@@ -272,8 +272,8 @@ describe('Scheduler', () => {
272272
Scheduler.unstable_yieldValue('High pri');
273273
});
274274
}
275-
if (tasks.length > 0 && shouldYield()) {
276-
Scheduler.unstable_yieldValue('Yield!');
275+
if (tasks.length > 0) {
276+
// Return a continuation
277277
return work;
278278
}
279279
}
@@ -283,9 +283,8 @@ describe('Scheduler', () => {
283283
'A',
284284
'B',
285285
'Schedule high pri',
286-
// Even though there's time left in the frame, the low pri callback
287-
// should yield to the high pri callback
288-
'Yield!',
286+
// The high pri callback should fire before the continuation of the
287+
// lower pri work
289288
'High pri',
290289
// Continue low pri work
291290
'C',
@@ -662,7 +661,7 @@ describe('Scheduler', () => {
662661
const [label, ms] = task;
663662
Scheduler.unstable_advanceTime(ms);
664663
Scheduler.unstable_yieldValue(label);
665-
if (tasks.length > 0 && shouldYield()) {
664+
if (tasks.length > 0) {
666665
return work;
667666
}
668667
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.