@@ -15,15 +15,14 @@ import org.jd.gui.view.SaveAllSourcesView
1515import java.nio.file.Files
1616import java.nio.file.Path
1717import java.nio.file.Paths
18- import java.util.concurrent.Callable
1918import java.util.concurrent.ExecutorService
2019
2120class SaveAllSourcesController implements SourcesSavable. Controller , SourcesSavable. Listener {
2221 API api
2322 SaveAllSourcesView saveAllSourcesView
2423 boolean cancel
2524 int counter
26- int step
25+ int mask
2726
2827 SaveAllSourcesController (SwingBuilder swing , Configuration configuration , API api ) {
2928 this . api = api
@@ -39,19 +38,20 @@ class SaveAllSourcesController implements SourcesSavable.Controller, SourcesSava
3938 executor. execute(new Runnable () {
4039 void run () {
4140 int fileCount = savable. fileCount
42- int quotient = (fileCount / 100 )
41+
42+ saveAllSourcesView. updateProgressBar(0 )
43+ saveAllSourcesView. setMaxValue(fileCount)
4344
4445 cancel = false
4546 counter = 0
46- step = 1
47+ mask = 2
4748
48- while (quotient > step) {
49- step << = 1
49+ while (fileCount > 64 ) {
50+ fileCount >>= 1
51+ mask << = 1
5052 }
51- step = (step >> 1 ) - 1
5253
53- saveAllSourcesView. updateProgressBar(counter)
54- saveAllSourcesView. setMaxValue(fileCount)
54+ mask--
5555
5656 def path = Paths . get(file. toURI())
5757 Files . deleteIfExists(path)
@@ -81,7 +81,7 @@ class SaveAllSourcesController implements SourcesSavable.Controller, SourcesSava
8181
8282 // --- SourcesSavable.Listener --- //
8383 void pathSaved (Path path ) {
84- if (((counter++ ) & step ) == 0 ) {
84+ if (((counter++ ) & mask ) == 0 ) {
8585 saveAllSourcesView. updateProgressBar(counter)
8686 }
8787 }
0 commit comments