Skip to content

Commit ef4f339

Browse files
committed
Minor optimisation
Changed from preg_match_all to preg_match as we only need the first result
1 parent d6298c0 commit ef4f339

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

face.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ function get_skin($user)
4646
$result = curl_exec($ch);
4747
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
4848
if ($status == 301) {
49-
preg_match_all('/location:(.*)/i', $result, $matches);
50-
curl_setopt($ch, CURLOPT_URL, trim(array_pop($matches[1])));
49+
preg_match('/location:(.*)/i', $result, $matches);
50+
curl_setopt($ch, CURLOPT_URL, trim($matches[1]));
5151
curl_setopt($ch, CURLOPT_HEADER, 0);
5252
curl_setopt($ch, CURLOPT_NOBODY, 0);
5353
$result = curl_exec($ch);

skin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ function get_skin($user)
4444
$result = curl_exec($ch);
4545
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
4646
if ($status == 301) {
47-
preg_match_all('/location:(.*)/i', $result, $matches);
48-
curl_setopt($ch, CURLOPT_URL, trim(array_pop($matches[1])));
47+
preg_match('/location:(.*)/i', $result, $matches);
48+
curl_setopt($ch, CURLOPT_URL, trim($matches[1]));
4949
curl_setopt($ch, CURLOPT_HEADER, 0);
5050
curl_setopt($ch, CURLOPT_NOBODY, 0);
5151
$result = curl_exec($ch);

0 commit comments

Comments
 (0)