Skip to content

Commit f899b11

Browse files
authored
Merge pull request #9677 from mbien/tiny-startup-splash-optimization
Small splash startup optimization
2 parents 0dd50a9 + 1b24e05 commit f899b11

1 file changed

Lines changed: 18 additions & 17 deletions

File tree

  • platform/core.startup/src/org/netbeans/core/startup

‎platform/core.startup/src/org/netbeans/core/startup/Splash.java‎

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ private static class Progress {
300300
private volatile int barLength = 0;
301301
private volatile String text;
302302

303+
private long next;
304+
303305
private void increment(SplashPainter painter, int steps) {
304306
if (steps <= 0) {
305307
return;
@@ -311,12 +313,15 @@ private void increment(SplashPainter painter, int steps) {
311313
int bl = painter.bar.width * progress / maxSteps - barStart;
312314
if (bl > 1 || barStart % 2 == 0) {
313315
barLength = bl;
314-
onEDT(() -> {
315-
/* Don't try to be smart about which section of the bar to repaint.
316-
There can be tricky rounding issues on HiDPI screens with non-integral
317-
scaling factors (e.g. 150%). */
318-
painter.repaint(painter.bar);
319-
});
316+
if (next < System.currentTimeMillis()) {
317+
onEDT(() -> {
318+
/* Don't try to be smart about which section of the bar to repaint.
319+
There can be tricky rounding issues on HiDPI screens with non-integral
320+
scaling factors (e.g. 150%). */
321+
painter.repaint(painter.bar);
322+
});
323+
next = System.currentTimeMillis() + 50;
324+
}
320325
}
321326
}
322327
}
@@ -546,21 +551,17 @@ public SplashPainter(Progress model, Graphics graphics, JComponent comp, boolean
546551
}
547552
}
548553

549-
long next;
550554
final void repaint(Rectangle r) {
551555
if (comp != null) {
552556
comp.repaint(r);
553557
} else {
554-
if (next < System.currentTimeMillis()) {
555-
paint();
556-
try {
557-
SplashScreen ss = SplashScreen.getSplashScreen();
558-
if (ss != null) {
559-
ss.update();
560-
}
561-
} catch (IllegalStateException splashAlreadyClosed) {}
562-
next = System.currentTimeMillis() + 200;
563-
}
558+
paint();
559+
try {
560+
SplashScreen ss = SplashScreen.getSplashScreen();
561+
if (ss != null) {
562+
ss.update();
563+
}
564+
} catch (IllegalStateException splashAlreadyClosed) {}
564565
}
565566
}
566567

0 commit comments

Comments
 (0)