Currently we have a linter rule (`ArcanistSlownessXHPASTLinterRule`) which recommends that `strncmp()` is used instead of `strpos()` for checking whether a string starts with some substring. It seems that this was added in D3296.
I am having trouble understanding the reasoning behind this linter rule. From some initial benchmarking, `strpos` seems to be more performant than `strncmp`. From a comment on http://php.net/manual/en/function.strncmp.php:
```lang=php
<?php
$haystack = "abcdefghijklmnopqrstuvwxyz";
$needles = array('abc', 'xyz', '123');
foreach ($needles as $needle) {
$times['strncmp'][$needle] = -microtime(true);
for ($i = 0; $i < 1000000; $i++) {
$result = strncmp($haystack, $needle, 3) === 0;
}
$times['strncmp'][$needle] += microtime(true);
}
foreach ($needles as $needle) {
$times['strpos'][$needle] = -microtime(true);
for ($i = 0; $i < 1000000; $i++) {
$result = strpos($haystack, $needle) === 0;
}
$times['strpos'][$needle] += microtime(true);
}
var_export($times);
```
On my machine (running PHP 5.6.4), running this script produces the following output:
```
array (
'strncmp' =>
array (
'abc' => 0.76744794845581055,
'xyz' => 0.73814797401428223,
123 => 0.74603605270385742,
),
'strpos' =>
array (
'abc' => 0.6839301586151123,
'xyz' => 0.68808603286743164,
123 => 0.67514586448669434,
),
)
```