Showing 4 changed files with 11 additions and 5 deletions
+1
Changes
... ...
@@ -1,4 +1,5 @@
1 1
 0.2101
2
+    - micro optimization
2 3
     - select method can receive odd number argument. In that case first argument
3 4
       is column option.
4 5
     - fixed update_or_insert bug that when parameter don't contain any key-value
+4 -1
lib/DBIx/Custom.pm
... ...
@@ -1259,12 +1259,15 @@ sub _create_query {
1259 1259
         else {
1260 1260
             my @columns;
1261 1261
             my $c = $self->{safety_character};
1262
+            my $re = $c eq 'a-zA-Z0-9_'
1263
+              ? qr/(.*?[^\\]):([$c\.]+)(?:\{(.*?)\})?(.*)/so
1264
+              : qr/(.*?[^\\]):([$c\.]+)(?:\{(.*?)\})?(.*)/s;
1262 1265
             my %duplicate;
1263 1266
             my $duplicate;
1264 1267
             # Parameter regex
1265 1268
             $sql =~ s/([0-9]):/$1\\:/g;
1266 1269
             my $new_sql = '';
1267
-            while ($sql =~ /(.*?[^\\]):([$c\.]+)(?:\{(.*?)\})?(.*)/s) {
1270
+            while ($sql =~ /$re/) {
1268 1271
                 push @columns, $2;
1269 1272
                 $duplicate = 1 if ++$duplicate{$columns[-1]} > 1;
1270 1273
                 ($new_sql, $sql) = defined $3 ?
+6 -3
lib/DBIx/Custom/Where.pm
... ...
@@ -37,7 +37,10 @@ sub to_string {
37 37
     my $where = [];
38 38
     my $count = {};
39 39
     $self->{_query_builder} = $self->dbi->query_builder;
40
-    $self->{_safety_character} = $self->dbi->safety_character;
40
+    my $c = $self->dbi->safety_character;
41
+    $self->{_re} = $c eq 'a-zA-Z0-9_' ?
42
+      qr/[^\\]:([$c\.]+)/so : qr/[^\\]:([$c\.]+)/s;
43
+    
41 44
     $self->{_quote} = $self->dbi->_quote;
42 45
     $self->{_tag_parse} = exists $ENV{DBIX_CUSTOM_TAG_PARSE}
43 46
       ? $ENV{DBIX_CUSTOM_TAG_PARSE} : $self->dbi->{tag_parse};
... ...
@@ -90,7 +93,7 @@ sub _parse {
90 93
         my $pushed;
91 94
         
92 95
         # Column
93
-        my $c = $self->{_safety_character};
96
+        my $re = $self->{_re};
94 97
         
95 98
         my $column;
96 99
         my $sql = " " . $clause || '';
... ...
@@ -100,7 +103,7 @@ sub _parse {
100 103
         }
101 104
         else {
102 105
             $sql =~ s/([0-9]):/$1\\:/g;
103
-            ($column) = $sql =~ /[^\\]:([$c\.]+)/s;
106
+            ($column) = $sql =~ /$re/;
104 107
         }
105 108
         unless (defined $column) {
106 109
             push @$where, $clause;
-1
t/common.t
... ...
@@ -243,7 +243,6 @@ test 'execute reuse option';
243 243
 eval { $dbi->execute("drop table $table1") };
244 244
 $dbi->execute($create_table1);
245 245
 $reuse = {};
246
-$DB::single = 1;
247 246
 for my $i (1 .. 2) {
248 247
   $dbi->insert({$key1 => 1, $key2 => 2}, table => $table1, reuse => $reuse);
249 248
 }