You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ca...@apache.org on 2019/04/14 10:56:26 UTC

[royale-compiler] branch develop updated: Fixes #83, wrap FileWriter with BufferedWriter to reduce IO operations

This is an automated email from the ASF dual-hosted git repository.

carlosrovira pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git


The following commit(s) were added to refs/heads/develop by this push:
     new e75745a  Fixes #83, wrap FileWriter with BufferedWriter to reduce IO operations
     new 522cd0e  Merge pull request #84 from bd2019us/PATCH-83
e75745a is described below

commit e75745a10fa02f5e2506b3cb0da0e28b8f996cba
Author: bd2019us <bd...@126.com>
AuthorDate: Sun Apr 14 00:39:04 2019 -0500

    Fixes #83, wrap FileWriter with BufferedWriter to reduce IO operations
---
 .../js/royale/JSRoyaleASDocDITAEmitter.java        | 25 ++++++++--------
 .../codegen/js/royale/JSRoyaleASDocEmitter.java    | 33 +++++++++++-----------
 2 files changed, 30 insertions(+), 28 deletions(-)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleASDocDITAEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleASDocDITAEmitter.java
index 266a0d6..2927115 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleASDocDITAEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleASDocDITAEmitter.java
@@ -20,6 +20,7 @@
 package org.apache.royale.compiler.internal.codegen.js.royale;
 
 import java.io.File;
+import java.io.BufferedWriter;
 import java.io.FileWriter;
 import java.io.FilterWriter;
 import java.io.IOException;
@@ -1015,10 +1016,10 @@ public class JSRoyaleASDocDITAEmitter extends JSGoogEmitter implements IJSRoyale
     
     public void outputIndex(File outputFolder, RoyaleASDocProject project) throws IOException
     {
-	    final File indexFile = new File(outputFolder, "index.json");
-	    FileWriter out = new FileWriter(indexFile);
-		out.write("{  \"index\": [");
-	    System.out.println("Compiling file: " + indexFile);
+	final File indexFile = new File(outputFolder, "index.json");
+	BufferedWriter out = new BufferedWriter(new FileWriter(indexFile));
+	out.write("{  \"index\": [");
+	System.out.println("Compiling file: " + indexFile);
     	Set<String> keys = project.index.keySet();
     	List<String> keyList = new ArrayList<String>(keys);
     	Collections.sort(keyList);
@@ -1084,10 +1085,10 @@ public class JSRoyaleASDocDITAEmitter extends JSGoogEmitter implements IJSRoyale
 
     public void outputClasses(File outputFolder, RoyaleASDocProject project) throws IOException
     {
-	    final File indexFile = new File(outputFolder, "classes.json");
-	    FileWriter out = new FileWriter(indexFile);
-		out.write("{  \"classes\": [");
-	    System.out.println("Compiling file: " + indexFile);
+	final File indexFile = new File(outputFolder, "classes.json");
+	BufferedWriter out = new BufferedWriter(new FileWriter(indexFile));
+	out.write("{  \"classes\": [");
+	System.out.println("Compiling file: " + indexFile);
     	Set<String> keys = project.classes.keySet();
     	List<String> keyList = new ArrayList<String>(keys);
     	Collections.sort(keyList);
@@ -1122,10 +1123,10 @@ public class JSRoyaleASDocDITAEmitter extends JSGoogEmitter implements IJSRoyale
     
     public void outputTags(File outputFolder, RoyaleASDocProject project) throws IOException
     {
-	    final File indexFile = new File(outputFolder, "tags.json");
-	    FileWriter out = new FileWriter(indexFile);
-		out.write("{  \"tags\": [");
-	    System.out.println("Compiling file: " + indexFile);
+	final File indexFile = new File(outputFolder, "tags.json");
+	BufferedWriter out = new BufferedWriter(new FileWriter(indexFile));
+	out.write("{  \"tags\": [");
+	System.out.println("Compiling file: " + indexFile);
     	Collections.sort(project.tags);
     	boolean firstLine = true;
     	for (String tag : project.tags)
diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleASDocEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleASDocEmitter.java
index 0157795..c40332c 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleASDocEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleASDocEmitter.java
@@ -19,6 +19,7 @@
 
 package org.apache.royale.compiler.internal.codegen.js.royale;
 
+import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.FilterWriter;
@@ -813,10 +814,10 @@ public class JSRoyaleASDocEmitter extends JSGoogEmitter implements IJSRoyaleEmit
 
     public void outputIndex(File outputFolder, RoyaleASDocProject project) throws IOException
     {
-	    final File indexFile = new File(outputFolder, "index" + getMiddle(project) + ".json");
-	    FileWriter out = new FileWriter(indexFile);
-		out.write("{  \"index\": [");
-	    System.out.println("Compiling file: " + indexFile);
+	final File indexFile = new File(outputFolder, "index" + getMiddle(project) + ".json");
+	BufferedWriter out = new BufferedWriter(new FileWriter(indexFile));
+	out.write("{  \"index\": [");
+	System.out.println("Compiling file: " + indexFile);
     	Set<String> keys = project.index.keySet();
     	List<String> keyList = new ArrayList<String>(keys);
     	Collections.sort(keyList);
@@ -896,7 +897,7 @@ public class JSRoyaleASDocEmitter extends JSGoogEmitter implements IJSRoyaleEmit
     	return false;
     }
     
-    private void writeCommentaryValues(FileWriter commentaryWriter, List<IASDocTag> values) throws IOException
+    private void writeCommentaryValues(BufferedWriter commentaryWriter, List<IASDocTag> values) throws IOException
     {
     	HashMap<String, String> map = new HashMap<String, String>();
 		boolean firstOne = true;
@@ -916,7 +917,7 @@ public class JSRoyaleASDocEmitter extends JSGoogEmitter implements IJSRoyaleEmit
 		}
     }
     
-    public void writeCommentaryFile(FileWriter commentaryWriter, String qname, ASDocComment asDoc) throws IOException
+    public void writeCommentaryFile(BufferedWriter commentaryWriter, String qname, ASDocComment asDoc) throws IOException
     {
     	//asDoc.compile();
     	Map<String, List<IASDocTag>> tags = asDoc.getTags();
@@ -1004,10 +1005,10 @@ public class JSRoyaleASDocEmitter extends JSGoogEmitter implements IJSRoyaleEmit
 
     public void outputClasses(File outputFolder, RoyaleASDocProject project) throws IOException
     {
-	    final File indexFile = new File(outputFolder, "classes" + getMiddle(project) + ".json");
-	    FileWriter out = new FileWriter(indexFile);
-		out.write("{  \"classes\": [");
-	    System.out.println("Compiling file: " + indexFile);
+	final File indexFile = new File(outputFolder, "classes" + getMiddle(project) + ".json");
+	BufferedWriter out = new BufferedWriter(new FileWriter(indexFile));
+        out.write("{  \"classes\": [");
+	System.out.println("Compiling file: " + indexFile);
     	Set<String> keys = project.classes.keySet();
     	List<String> keyList = new ArrayList<String>(keys);
     	Collections.sort(keyList);
@@ -1065,7 +1066,7 @@ public class JSRoyaleASDocEmitter extends JSGoogEmitter implements IJSRoyaleEmit
 		}
 		
 	    final File listFile = new File(outputFolder, "classlist" + getMiddle(project) + ".json");
-	    out = new FileWriter(listFile);
+	    out = new BufferedWriter(new FileWriter(listFile));
 		out.write("{  \"classnames\": [");
 	    System.out.println("Compiling file: " + listFile);
     	firstLine = true;
@@ -1096,7 +1097,7 @@ public class JSRoyaleASDocEmitter extends JSGoogEmitter implements IJSRoyaleEmit
 		
 		if (commentaryList.size() > 0) {    	
 			final File commentaryFile = new File(outputFolder, "commentary" + getMiddle(project) + ".json");
-			FileWriter commentaryWriter = new FileWriter(commentaryFile);
+			BufferedWriter commentaryWriter = new BufferedWriter(new FileWriter(commentaryFile));
 			commentaryWriter.write("{ \"list\": [");
 			System.out.println("Building commentary comparison file: "+commentaryFile);
 			
@@ -1129,10 +1130,10 @@ public class JSRoyaleASDocEmitter extends JSGoogEmitter implements IJSRoyaleEmit
     
     public void outputTags(File outputFolder, RoyaleASDocProject project) throws IOException
     {
-	    final File indexFile = new File(outputFolder, "tags" + getMiddle(project) + ".json");
-	    FileWriter out = new FileWriter(indexFile);
-		out.write("{  \"tags\": [");
-	    System.out.println("Compiling file: " + indexFile);
+	final File indexFile = new File(outputFolder, "tags" + getMiddle(project) + ".json");
+	BufferedWriter out = new BufferedWriter(new FileWriter(indexFile));
+	out.write("{  \"tags\": [");
+	System.out.println("Compiling file: " + indexFile);
     	Collections.sort(project.tags);
     	boolean firstLine = true;
     	for (String tag : project.tags)