summaryrefslogtreecommitdiffstats
path: root/system/libraries/Image_lib.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-11-12 16:21:01 +0100
committerAndrey Andreev <narf@bofh.bg>2012-11-12 16:21:01 +0100
commit7a7ad782b2f125622509a77c5a6f94ad4ae0f93c (patch)
tree8b849b80e51492877c60a7b976d33a0ddba68d46 /system/libraries/Image_lib.php
parenta9ab46d7a031bda304eb9b6658ffaf693b8d9bcb (diff)
Some micro-optimizations
Diffstat (limited to 'system/libraries/Image_lib.php')
-rw-r--r--system/libraries/Image_lib.php12
1 files changed, 6 insertions, 6 deletions
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 9379e3ec8..7f937f99b 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -605,7 +605,7 @@ class CI_Image_lib {
// Set the quality
$this->quality = trim(str_replace('%', '', $this->quality));
- if ($this->quality === '' OR $this->quality === 0 OR ! preg_match('/^[0-9]+$/', $this->quality))
+ if ($this->quality === '' OR $this->quality === 0 OR ! ctype_digit($this->quality))
{
$this->quality = 90;
}
@@ -1277,8 +1277,8 @@ class CI_Image_lib {
if ($this->wm_use_drop_shadow === FALSE)
$this->wm_shadow_distance = 0;
- $this->wm_vrt_alignment = strtoupper(substr($this->wm_vrt_alignment, 0, 1));
- $this->wm_hor_alignment = strtoupper(substr($this->wm_hor_alignment, 0, 1));
+ $this->wm_vrt_alignment = strtoupper($this->wm_vrt_alignment[0]);
+ $this->wm_hor_alignment = strtoupper($this->wm_hor_alignment[0]);
// Set verticle alignment
if ($this->wm_vrt_alignment === 'M')
@@ -1518,13 +1518,13 @@ class CI_Image_lib {
public function image_reproportion()
{
if (($this->width === 0 && $this->height === 0) OR $this->orig_width === 0 OR $this->orig_height === 0
- OR ( ! preg_match('/^[0-9]+$/', $this->width) && ! preg_match('/^[0-9]+$/', $this->height))
- OR ! preg_match('/^[0-9]+$/', $this->orig_width) OR ! preg_match('/^[0-9]+$/', $this->orig_height))
+ OR ( ! ctype_digit((string) $this->width) && ! ctype_digit((string) $this->height))
+ OR ! ctype_digit((string) $this->orig_width) OR ! ctype_digit((string) $this->orig_height))
{
return;
}
- // Sanitize so we don't call preg_match() anymore
+ // Sanitize
$this->width = (int) $this->width;
$this->height = (int) $this->height;