From b604a67c50bf720509e9d3cb26b9c54075a0951f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 4 Aug 2011 16:15:13 +0200 Subject: [PATCH] Optimize matching - avoid calling twice same preg_match - do case sensitive match as we have the string in lower case --- libraries/common.lib.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 9ad8eadacb..4fdc6739d4 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -2636,20 +2636,16 @@ function PMA_extractFieldSpec($fieldspec) { // strip the "BINARY" attribute, except if we find "BINARY(" because // this would be a BINARY or VARBINARY field type - if (!preg_match('@BINARY[\(]@i', $shorttype)) { - $shorttype = preg_replace('@BINARY@i', '', $shorttype); + if (!preg_match('@binary[\(]@', $shorttype)) { + $binary = strstr($shorttype, 'blob') || strstr($shorttype, 'binary'); + $shorttype = preg_replace('@binary@', '', $shorttype); } - $shorttype = preg_replace('@ZEROFILL@i', '', $shorttype); - $shorttype = preg_replace('@UNSIGNED@i', '', $shorttype); + $zerofill = strstr($shorttype, 'zerofill'); + $shorttype = preg_replace('@zerofill@', '', $shorttype); + $unsigned = strstr($shorttype, 'unsigned'); + $shorttype = preg_replace('@unsigned@', '', $shorttype); $shorttype = trim($shorttype); - if (!preg_match('@BINARY[\(]@i', $fieldspec)) { - $binary = stristr($fieldspec, 'blob') || stristr($fieldspec, 'binary'); - } else { - $binary = false; - } - $unsigned = stristr($fieldspec, 'unsigned'); - $zerofill = stristr($fieldspec, 'zerofill'); } return array(