From: Jamie McCracken Date: Tue, 27 May 2008 05:05:28 +0000 (+0000) Subject: Improved performance of print statement X-Git-Tag: VALA_0_3_3~101 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6f07fe74e8bd7ade12efe40e17fa77e96f071b42;p=platform%2Fupstream%2Fvala.git Improved performance of print statement 2008-05-27 Jamie McCracken * vala/valagenieparser.vala: Improved performance of print statement svn path=/trunk/; revision=1457 --- diff --git a/ChangeLog b/ChangeLog index 39db469..1454a38 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,12 @@ 2008-05-27 Jamie McCracken * vala/valagenieparser.vala: + + Improved performance of print statement + +2008-05-27 Jamie McCracken + + * vala/valagenieparser.vala: * vala/valageniescanner.vala: Added optional indent attribute to allow spaces to be used in lieu of tabs for indents diff --git a/vala/valagenieparser.vala b/vala/valagenieparser.vala index fa5989c..2c8410a 100644 --- a/vala/valagenieparser.vala +++ b/vala/valagenieparser.vala @@ -638,9 +638,22 @@ public class Vala.Genie.Parser : CodeVisitor { i++; if (p_expr != null) { - string s = "\"\\n\""; - var rhs = new StringLiteral (s, get_src (begin)); - p_expr = new BinaryExpression (BinaryOperator.PLUS, p_expr, rhs, get_src (begin)); + string s = "\\n\""; + + if (p_expr is StringLiteral) { + var s_exp = (StringLiteral) p_expr; + var len = s_exp.value.size (); + + if (len > 2) { + var st = s_exp.value.ndup (len-1); + st += s; + s_exp.value = st; + } + } else { + string s = "\"\\n\""; + var rhs = new StringLiteral (s, get_src (begin)); + p_expr = new BinaryExpression (BinaryOperator.PLUS, p_expr, rhs, get_src (begin)); + } } }