Optimize offsetGet #506
Merged
Optimize offsetGet #506
Annotations
1 error and 10 warnings
|
src/UtfString.php#L80
Escaped Mutant for Mutator "MBString":
--- Original
+++ New
@@ @@
public function __construct($str)
{
$this->str = $str;
- $this->byteLen = mb_strlen($str, '8bit');
+ $this->byteLen = strlen($str);
if (!mb_check_encoding($str, 'UTF-8')) {
$this->charLen = 0;
} else {
|
src/UtfString.php#L82
Escaped Mutant for Mutator "DecrementInteger":
--- Original
+++ New
@@ @@
$this->str = $str;
$this->byteLen = mb_strlen($str, '8bit');
if (!mb_check_encoding($str, 'UTF-8')) {
- $this->charLen = 0;
+ $this->charLen = -1;
} else {
$this->charLen = mb_strlen($str, 'UTF-8');
}
|
src/UtfString.php#L95
Escaped Mutant for Mutator "GreaterThanOrEqualTo":
--- Original
+++ New
@@ @@
*/
public function offsetExists($offset) : bool
{
- return $offset >= 0 && $offset < $this->charLen;
+ return $offset > 0 && $offset < $this->charLen;
}
/**
* Gets the character at given offset.
|
src/UtfString.php#L117
Escaped Mutant for Mutator "GreaterThan":
--- Original
+++ New
@@ @@
return null;
}
$delta = $offset - $this->charIdx;
- if ($delta > 0) {
+ if ($delta >= 0) {
// Fast forwarding.
$this->byteIdx += strlen(mb_substr(substr($this->str, $this->byteIdx, 4 * $delta), 0, $delta));
$this->charIdx += $delta;
|
src/UtfString.php#L119
Escaped Mutant for Mutator "IncrementInteger":
--- Original
+++ New
@@ @@
$delta = $offset - $this->charIdx;
if ($delta > 0) {
// Fast forwarding.
- $this->byteIdx += strlen(mb_substr(substr($this->str, $this->byteIdx, 4 * $delta), 0, $delta));
+ $this->byteIdx += strlen(mb_substr(substr($this->str, $this->byteIdx, 5 * $delta), 0, $delta));
$this->charIdx += $delta;
} elseif ($delta < 0) {
// Rewinding.
|
src/UtfString.php#L121
Escaped Mutant for Mutator "LessThan":
--- Original
+++ New
@@ @@
// Fast forwarding.
$this->byteIdx += strlen(mb_substr(substr($this->str, $this->byteIdx, 4 * $delta), 0, $delta));
$this->charIdx += $delta;
- } elseif ($delta < 0) {
+ } elseif ($delta <= 0) {
// Rewinding.
while ($delta++ < 0) {
// We rewind byte by byte and only count characters that are not continuation bytes,
|
src/UtfString.php#L128
Escaped Mutant for Mutator "GreaterThanOrEqualTo":
--- Original
+++ New
@@ @@
// i.e. ASCII characters and first octets of multibyte characters
do {
$byte = ord($this->str[--$this->byteIdx]);
- } while ($byte >= 128 && $byte < 192);
+ } while ($byte > 128 && $byte < 192);
--$this->charIdx;
}
}
|
src/UtfString.php#L128
Escaped Mutant for Mutator "LessThan":
--- Original
+++ New
@@ @@
// i.e. ASCII characters and first octets of multibyte characters
do {
$byte = ord($this->str[--$this->byteIdx]);
- } while ($byte >= 128 && $byte < 192);
+ } while ($byte >= 128 && $byte <= 192);
--$this->charIdx;
}
}
|
src/UtfString.php#L135
Escaped Mutant for Mutator "IncrementInteger":
--- Original
+++ New
@@ @@
}
}
// Fetch the first Unicode character within the next 4 bytes in the string.
- return mb_substr(substr($this->str, $this->byteIdx, 4), 0, 1);
+ return mb_substr(substr($this->str, $this->byteIdx, 5), 0, 1);
}
/**
* Sets the value of a character.
|
The `set-output` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
|
The logs for this run have expired and are no longer available.
Loading