WP_Token_Map::read_small_token
Finds a match for a short word at the index.
Метод класса: WP_Token_Map{}
Хуков нет.
Возвращает
string|null. Mapped value of lookup key if found, otherwise null.
Использование
// private - только в коде основоного (родительского) класса $result = $this->read_small_token( $text, $offset, $matched_token_byte_length, $case_sensitivity ): ?string;
- $text(строка) (обязательный)
- String in which to search for a lookup key.
- $offset(int)
- How many bytes into the string where the lookup key ought to start.
- $matched_token_byte_length(передается по ссылке — &)
- .
По умолчанию:null - $case_sensitivity(строка)
- Pass
'ascii-case-insensitive'to ignore ASCII case when matching.
По умолчанию:'case-sensitive'
Список изменений
| С версии 6.6.0 | Введена. |
Код WP_Token_Map::read_small_token() WP Token Map::read small token WP 7.1.2
private function read_small_token( string $text, int $offset = 0, &$matched_token_byte_length = null, $case_sensitivity = 'case-sensitive' ): ?string {
$ignore_case = 'ascii-case-insensitive' === $case_sensitivity;
$small_length = strlen( $this->small_words );
$search_text = substr( $text, $offset, $this->key_length );
if ( $ignore_case ) {
$search_text = strtoupper( $search_text );
}
$starting_char = $search_text[0];
$at = 0;
while ( $at < $small_length ) {
if (
$starting_char !== $this->small_words[ $at ] &&
( ! $ignore_case || strtoupper( $this->small_words[ $at ] ) !== $starting_char )
) {
$at += $this->key_length + 1;
continue;
}
for ( $adjust = 1; $adjust < $this->key_length; $adjust++ ) {
if ( "\x00" === $this->small_words[ $at + $adjust ] ) {
$matched_token_byte_length = $adjust;
return $this->small_mappings[ $at / ( $this->key_length + 1 ) ];
}
if (
$search_text[ $adjust ] !== $this->small_words[ $at + $adjust ] &&
( ! $ignore_case || strtoupper( $this->small_words[ $at + $adjust ] !== $search_text[ $adjust ] ) )
) {
$at += $this->key_length + 1;
continue 2;
}
}
$matched_token_byte_length = $adjust;
return $this->small_mappings[ $at / ( $this->key_length + 1 ) ];
}
return null;
}