[vala/wip/housekeeping] writer: Some string optimizations
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/housekeeping] writer: Some string optimizations
- Date: Tue, 1 Nov 2016 07:41:19 +0000 (UTC)
commit 0740e6923ae32a8b2aef171b6c4f4b7562f91d07
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Nov 1 08:16:50 2016 +0100
writer: Some string optimizations
ccode/valaccodewriter.vala | 5 +----
vala/valacodewriter.vala | 23 +++++++++--------------
2 files changed, 10 insertions(+), 18 deletions(-)
---
diff --git a/ccode/valaccodewriter.vala b/ccode/valaccodewriter.vala
index 93f4a42..7dc101e 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 1d83a20..8414d2d 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -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 {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]