groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 03/04: Trivial refactoring: simplify code with `Map.computeIfAbsent`
Date Sat, 11 Jan 2020 17:31:04 GMT
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit f52a5f91ad1f03dd0cbf8d66dc3961d262bebb74
Author: Daniel Sun <sunlan@apache.org>
AuthorDate: Sun Jan 12 01:26:17 2020 +0800

    Trivial refactoring: simplify code with `Map.computeIfAbsent`
---
 .../org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java   | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
index 68b6962..69f1177 100644
--- a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
+++ b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
@@ -923,11 +923,7 @@ public class SimpleGroovyClassDoc extends SimpleGroovyAbstractableElementDoc
imp
                     }
                     if (TAG_TEXT.containsKey(tagname)) {
                         String text = TAG_TEXT.get(tagname);
-                        List<String> contents = savedTags.get(text);
-                        if (contents == null) {
-                            contents = new ArrayList<String>();
-                            savedTags.put(text, contents);
-                        }
+                        List<String> contents = savedTags.computeIfAbsent(text, k ->
new ArrayList<String>());
                         contents.add(content);
                         matcher.appendReplacement(sb, "");
                     } else {


Mime
View raw message