Skip to content

Commit

Permalink
Minor optimisation
Browse files Browse the repository at this point in the history
Changed from preg_match_all to preg_match as we only need the first
result
  • Loading branch information
jamiebicknell committed Mar 24, 2015
1 parent d6298c0 commit ef4f339
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions face.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ function get_skin($user)
$result = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status == 301) {
preg_match_all('/location:(.*)/i', $result, $matches);
curl_setopt($ch, CURLOPT_URL, trim(array_pop($matches[1])));
preg_match('/location:(.*)/i', $result, $matches);
curl_setopt($ch, CURLOPT_URL, trim($matches[1]));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_NOBODY, 0);
$result = curl_exec($ch);
Expand Down
4 changes: 2 additions & 2 deletions skin.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ function get_skin($user)
$result = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status == 301) {
preg_match_all('/location:(.*)/i', $result, $matches);
curl_setopt($ch, CURLOPT_URL, trim(array_pop($matches[1])));
preg_match('/location:(.*)/i', $result, $matches);
curl_setopt($ch, CURLOPT_URL, trim($matches[1]));
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_NOBODY, 0);
$result = curl_exec($ch);
Expand Down

0 comments on commit ef4f339

Please sign in to comment.