Kaynağa Gözat

Small refactors for cleanliness

Anthony Jordan 6 yıl önce
ebeveyn
işleme
3ef00aae72

+ 0
- 2
src/main/java/io/zipcoder/MonkeyTypewriter.java Dosyayı Görüntüle

@@ -31,7 +31,6 @@ public class MonkeyTypewriter {
31 31
         for (Thread thread: unsafeArray) {
32 32
             thread.start();
33 33
         }
34
-        unsafeCopier.copied = unsafeCopier.copied.substring(1, unsafeCopier.copied.length());
35 34
 
36 35
         SafeCopier safeCopier = new SafeCopier(introduction);
37 36
         Thread[] safeArray = new Thread[5];
@@ -42,7 +41,6 @@ public class MonkeyTypewriter {
42 41
             thread.start();
43 42
         }
44 43
 
45
-        safeCopier.copied = safeCopier.copied.substring(1, safeCopier.copied.length());
46 44
 
47 45
         // This wait is here because main is still a thread and we want the main method to print the finished copies
48 46
         // after enough time has passed.

+ 1
- 1
src/main/java/io/zipcoder/SafeCopier.java Dosyayı Görüntüle

@@ -20,7 +20,7 @@ public class SafeCopier extends Copier {
20 20
             lock.lock();
21 21
             if (stringIterator.hasNext()) {
22 22
                 String word = stringIterator.next();
23
-                copied = copied + " " + word;
23
+                copied += word + " ";
24 24
             }
25 25
             lock.unlock();
26 26
         }

+ 1
- 1
src/main/java/io/zipcoder/UnsafeCopier.java Dosyayı Görüntüle

@@ -15,7 +15,7 @@ public class UnsafeCopier extends Copier {
15 15
         try {
16 16
             while (stringIterator.hasNext()) {
17 17
                 String word = stringIterator.next();
18
-                copied = copied + " " + word;
18
+                copied += word + " ";
19 19
             }
20 20
         } catch (NoSuchElementException e) { }
21 21
     }