[vala/wip/housekeeping: 6/6] Don't create constant Regex on demand and use static field where possible
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/housekeeping: 6/6] Don't create constant Regex on demand and use static field where possible
- Date: Tue, 1 Nov 2016 11:06:23 +0000 (UTC)
commit 44c6d06a2981528e473b1705ecce5955c6eaedeb
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Nov 1 10:29:45 2016 +0100
Don't create constant Regex on demand and use static field where possible
ccode/valaccodewriter.vala | 2 +-
vala/valacodewriter.vala | 7 +------
vala/valareport.vala | 7 +------
3 files changed, 3 insertions(+), 13 deletions(-)
---
diff --git a/ccode/valaccodewriter.vala b/ccode/valaccodewriter.vala
index b6a3238..57b28d8 100644
--- a/ccode/valaccodewriter.vala
+++ b/ccode/valaccodewriter.vala
@@ -220,7 +220,7 @@ public class Vala.CCodeWriter {
bool first = true;
// discard tabs at beginning of line
- var regex = new GLib.Regex ("^\t+");
+ var regex = /^\t+/;
foreach (unowned string line in text.split ("\n")) {
if (!first) {
diff --git a/vala/valacodewriter.vala b/vala/valacodewriter.vala
index 99a9725..7b08802 100644
--- a/vala/valacodewriter.vala
+++ b/vala/valacodewriter.vala
@@ -1502,12 +1502,7 @@ public class Vala.CodeWriter : CodeVisitor {
}
private void write_comment (Comment comment) {
- Regex fix_indent_regex;
- try {
- fix_indent_regex = new Regex ("\\n[\\t ]*");
- } catch (Error e) {
- assert_not_reached ();
- }
+ var fix_indent_regex = /\\n[\\t ]*/;
string replacement = "\n%s ".printf (string.nfill (indent, '\t'));
string fixed_content;
diff --git a/vala/valareport.vala b/vala/valareport.vala
index 67b3a80..f18e936 100644
--- a/vala/valareport.vala
+++ b/vala/valareport.vala
@@ -109,12 +109,7 @@ public class Vala.Report : Object {
* }}}
*/
public bool set_colors (string str) {
- Regex val_regex;
- try {
- val_regex = new Regex ("^\\s*[0-9]+(;[0-9]*)*\\s*$");
- } catch (RegexError e) {
- assert_not_reached ();
- }
+ var val_regex = /^\\s*[0-9]+(;[0-9]*)*\\s*$/;
string error_color = null;
string warning_color = null;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]