From b77b90a3edc140e131933de4a5aed18cf6c9fabf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 2 Dec 2016 13:41:21 +0100 Subject: [PATCH] Improve Internet::transliterate performance --- src/Faker/Provider/Internet.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Faker/Provider/Internet.php b/src/Faker/Provider/Internet.php index dfd9e56000..d4b0e23db2 100644 --- a/src/Faker/Provider/Internet.php +++ b/src/Faker/Provider/Internet.php @@ -209,6 +209,10 @@ public static function macAddress() protected static function transliterate($string) { + if (0 === preg_match('/[^A-Za-z0-9_.]/', $string)) { + return $string; + } + $transId = 'Any-Latin; Latin-ASCII; NFD; [:Nonspacing Mark:] Remove; NFC;'; if (function_exists('transliterator_transliterate') && $transliterator = \Transliterator::create($transId)) { $transString = $transliterator->transliterate($string);