You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by in...@apache.org on 2018/02/20 23:16:10 UTC
hadoop git commit: HDFS-13168. XmlImageVisitor - Prefer Array over
LinkedList. Contributed by BELUGA BEHR.
Repository: hadoop
Updated Branches:
refs/heads/trunk 9028ccaf8 -> 17c592e6c
HDFS-13168. XmlImageVisitor - Prefer Array over LinkedList. Contributed by BELUGA BEHR.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/17c592e6
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/17c592e6
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/17c592e6
Branch: refs/heads/trunk
Commit: 17c592e6cfd1ea3dbe9671c4703caabd095d87cf
Parents: 9028cca
Author: Inigo Goiri <in...@apache.org>
Authored: Tue Feb 20 15:16:01 2018 -0800
Committer: Inigo Goiri <in...@apache.org>
Committed: Tue Feb 20 15:16:01 2018 -0800
----------------------------------------------------------------------
.../tools/offlineImageViewer/XmlImageVisitor.java | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/17c592e6/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/XmlImageVisitor.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/XmlImageVisitor.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/XmlImageVisitor.java
index 44593a3..a326049 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/XmlImageVisitor.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/offlineImageViewer/XmlImageVisitor.java
@@ -18,16 +18,17 @@
package org.apache.hadoop.hdfs.tools.offlineImageViewer;
import java.io.IOException;
-import java.util.LinkedList;
+import java.util.ArrayDeque;
+import java.util.Deque;
import org.apache.hadoop.hdfs.util.XMLUtils;
+
/**
* An XmlImageVisitor walks over an fsimage structure and writes out
* an equivalent XML document that contains the fsimage's components.
*/
public class XmlImageVisitor extends TextWriterImageVisitor {
- final private LinkedList<ImageElement> tagQ =
- new LinkedList<ImageElement>();
+ final private Deque<ImageElement> tagQ = new ArrayDeque<>();
public XmlImageVisitor(String filename) throws IOException {
super(filename, false);
@@ -51,9 +52,10 @@ public class XmlImageVisitor extends TextWriterImageVisitor {
@Override
void leaveEnclosingElement() throws IOException {
- if(tagQ.size() == 0)
+ if (tagQ.isEmpty()) {
throw new IOException("Tried to exit non-existent enclosing element " +
- "in FSImage file");
+ "in FSImage file");
+ }
ImageElement element = tagQ.pop();
write("</" + element.toString() + ">\n");
@@ -71,7 +73,7 @@ public class XmlImageVisitor extends TextWriterImageVisitor {
@Override
void visitEnclosingElement(ImageElement element) throws IOException {
- write("<" + element.toString() + ">\n");
+ write('<' + element.toString() + ">\n");
tagQ.push(element);
}
@@ -79,12 +81,12 @@ public class XmlImageVisitor extends TextWriterImageVisitor {
void visitEnclosingElement(ImageElement element,
ImageElement key, String value)
throws IOException {
- write("<" + element.toString() + " " + key + "=\"" + value +"\">\n");
+ write('<' + element.toString() + ' ' + key + "=\"" + value +"\">\n");
tagQ.push(element);
}
private void writeTag(String tag, String value) throws IOException {
- write("<" + tag + ">" +
+ write('<' + tag + '>' +
XMLUtils.mangleXmlString(value, true) + "</" + tag + ">\n");
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org