summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2016-11-01 08:16:50 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2016-11-01 11:50:41 +0100
commit061d0e14742ee746fbbbb39afdfdfe5c8b5f84db (patch)
treeda569c2f4963321d9bdcc283e62038f210f9dfd8
parent2d7df5c505b09b90cd0ad236acb4a76b01d8288a (diff)
downloadvala-061d0e14742ee746fbbbb39afdfdfe5c8b5f84db.tar.gz
writer: Some string optimizations
-rw-r--r--ccode/valaccodewriter.vala5
-rw-r--r--vala/valacodewriter.vala25
2 files changed, 11 insertions, 19 deletions
diff --git a/ccode/valaccodewriter.vala b/ccode/valaccodewriter.vala
index 7368852d1..adcf18920 100644
--- a/ccode/valaccodewriter.vala
+++ b/ccode/valaccodewriter.vala
@@ -160,10 +160,7 @@ public class Vala.CCodeWriter {
write_newline ();
}
- for (int i = 0; i < indent; i++) {
- stream.putc ('\t');
- }
-
+ stream.puts (string.nfill (indent, '\t'));
_bol = false;
}
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index 1d83a202e..99a9725ae 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -67,7 +67,7 @@ public class Vala.CodeWriter : CodeVisitor {
*/
public void write_file (CodeContext context, string filename) {
var file_exists = FileUtils.test (filename, FileTest.EXISTS);
- var temp_filename = filename + ".valatmp";
+ var temp_filename = "%s.valatmp".printf (filename);
this.context = context;
if (file_exists) {
@@ -1493,16 +1493,11 @@ public class Vala.CodeWriter : CodeVisitor {
}
private void write_indent () {
- int i;
-
if (!bol) {
stream.putc ('\n');
}
-
- for (i = 0; i < indent; i++) {
- stream.putc ('\t');
- }
-
+
+ stream.puts (string.nfill (indent, '\t'));
bol = false;
}
@@ -1514,7 +1509,7 @@ public class Vala.CodeWriter : CodeVisitor {
assert_not_reached ();
}
- string replacement = "\n" + string.nfill (indent, '\t') + " ";
+ string replacement = "\n%s ".printf (string.nfill (indent, '\t'));
string fixed_content;
try {
fixed_content = fix_indent_regex.replace (comment.content, comment.content.length, 0, replacement);
@@ -1560,7 +1555,7 @@ public class Vala.CodeWriter : CodeVisitor {
}
private void write_string (string s) {
- stream.printf ("%s", s);
+ stream.puts (s);
bol = false;
}
@@ -1592,7 +1587,7 @@ public class Vala.CodeWriter : CodeVisitor {
private void write_end_block () {
indent--;
write_indent ();
- stream.printf ("}");
+ stream.putc ('}');
}
private bool check_accessibility (Symbol sym) {
@@ -1675,9 +1670,9 @@ public class Vala.CodeWriter : CodeVisitor {
stream.printf ("[%s", attr.name);
if (keys.get_length () > 0) {
- stream.printf (" (");
+ stream.puts (" (");
- string separator = "";
+ unowned string separator = "";
var arg_iter = keys.get_begin_iter ();
while (!arg_iter.is_end ()) {
unowned string arg_name = arg_iter.get ();
@@ -1690,9 +1685,9 @@ public class Vala.CodeWriter : CodeVisitor {
separator = ", ";
}
- stream.printf (")");
+ stream.puts (")");
}
- stream.printf ("]");
+ stream.puts ("]");
if (node is Parameter || node is PropertyAccessor) {
write_string (" ");
} else {