소스 검색

Small refactors for cleanliness

Anthony Jordan 6 년 전
부모
커밋
3ef00aae72
3개의 변경된 파일2개의 추가작업 그리고 4개의 파일을 삭제
  1. 0
    2
      src/main/java/io/zipcoder/MonkeyTypewriter.java
  2. 1
    1
      src/main/java/io/zipcoder/SafeCopier.java
  3. 1
    1
      src/main/java/io/zipcoder/UnsafeCopier.java

+ 0
- 2
src/main/java/io/zipcoder/MonkeyTypewriter.java 파일 보기

@@ -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 파일 보기

@@ -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 파일 보기

@@ -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
     }