Page MenuHomePhabricator

D19545.id46734.diff
No OneTemporary

D19545.id46734.diff

diff --git a/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php b/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
--- a/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
+++ b/src/applications/harbormaster/storage/build/HarbormasterBuildLog.php
@@ -643,7 +643,13 @@
$pos += $slice_length;
$map_bytes += $slice_length;
- $line_count += count(preg_split("/\r\n|\r|\n/", $slice)) - 1;
+
+ // Count newlines in the slice. This goofy approach is meaningfully
+ // faster than "preg_match_all()" or "preg_split()". See PHI766.
+ $n_rn = substr_count($slice, "\r\n");
+ $n_r = substr_count($slice, "\r");
+ $n_n = substr_count($slice, "\n");
+ $line_count += ($n_rn) + ($n_r - $n_rn) + ($n_n - $n_rn);
if ($map_bytes >= ($marker_distance - $max_utf8_width)) {
$map[] = array(

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 15, 3:42 PM (1 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7697030
Default Alt Text
D19545.id46734.diff (897 B)

Event Timeline