groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject groovy git commit: trivial refactor
Date Mon, 05 Sep 2016 01:15:06 GMT
Repository: groovy
Updated Branches:
  refs/heads/master 25dba7705 -> d6781a4a8


trivial refactor


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/d6781a4a
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/d6781a4a
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/d6781a4a

Branch: refs/heads/master
Commit: d6781a4a88aaa141b0a170bec220844a2e8a2d75
Parents: 25dba77
Author: paulk <paulk@asert.com.au>
Authored: Mon Sep 5 11:14:51 2016 +1000
Committer: paulk <paulk@asert.com.au>
Committed: Mon Sep 5 11:14:51 2016 +1000

----------------------------------------------------------------------
 .../org/codehaus/groovy/util/StringUtil.groovy  | 25 +++++++++++---------
 1 file changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/d6781a4a/src/main/org/codehaus/groovy/util/StringUtil.groovy
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/util/StringUtil.groovy b/src/main/org/codehaus/groovy/util/StringUtil.groovy
index d6820da..ed83e53 100644
--- a/src/main/org/codehaus/groovy/util/StringUtil.groovy
+++ b/src/main/org/codehaus/groovy/util/StringUtil.groovy
@@ -18,17 +18,20 @@
  */
 package org.codehaus.groovy.util
 
+import groovy.transform.CompileStatic
+
 /**
- * Provides Groovy with functionality similar to the unix tr command
- * which translates a string replacing characters from a source set
- * with characters from a replacement set.
- *
- * @author UEHARA Junji (uehaj)
- * @author NAKANO Yasuharu (nobeans)
- * @since 1.7.3
+ * String utility functions.
  */
+@CompileStatic
 class StringUtil {
-
+    /**
+     * Provides Groovy with functionality similar to the unix tr command
+     * which translates a string replacing characters from a source set
+     * with characters from a replacement set.
+     *
+     * @since 1.7.3
+     */
     static String tr(String text, String source, String replacement) {
         if (!text || !source) { return text }
         source = expandHyphen(source)
@@ -37,18 +40,18 @@ class StringUtil {
         // padding replacement with a last character, if necessary
         replacement = replacement.padRight(source.size(), replacement[replacement.size()
- 1])
 
-        return text.collect { original ->
+        return text.collect { String original ->
             if (source.contains(original)) {
                 replacement[source.lastIndexOf(original)]
             } else {
                 original
             }
-        }.join()
+        }.join('')
     }
 
     // no expansion for hyphen at start or end of Strings
     private static String expandHyphen(String text) {
         if (!text.contains('-')) { return text }
-        return text.replaceAll(/(.)-(.)/, { all, begin, end -> (begin..end).join() })
+        return text.replaceAll(/(.)-(.)/, { all, begin, end -> (begin..end).join('') })
     }
 }


Mime
View raw message