]> git.sesse.net Git - wloh/blobdiff - sync.pl
Small optimization to copy_escape.
[wloh] / sync.pl
diff --git a/sync.pl b/sync.pl
index d57af449979c05672fc658b0c930e7e28cf744ef..c57325965d93c9e4acf381bc057aff128f7ecbe9 100755 (executable)
--- a/sync.pl
+++ b/sync.pl
@@ -5,7 +5,8 @@ use warnings;
 no warnings qw(once);
 use Encode;
 use Time::HiRes;
-require './config.pm';
+use lib qw( include );
+require 'config.pm';
 
 sub copy_escape {
        my $x = shift;
@@ -13,10 +14,7 @@ sub copy_escape {
                return '\N';
        }
        $x = Encode::decode('iso8859-1', $x);
-       $x =~ s/\\/\\\\/g;
-       $x =~ s/\r/\\r/g;
-       $x =~ s/\n/\\n/g;
-       $x =~ s/\t/\\t/g;
+       $x =~ s/([\\\r\n\t])/\\$1/g;
        return $x;
 }