Package io.netty.util.internal
Class SWARUtil
java.lang.Object
io.netty.util.internal.SWARUtil
Utility class for SWAR (SIMD within a register) operations.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static int
applyLowerCasePattern
(int word) Returns a word where each lowercase ASCII byte has the highest bit set.private static long
applyLowerCasePattern
(long word) Returns a word where each ASCII lowercase byte has the highest bit set.static long
applyPattern
(long word, long pattern) Applies a compiled pattern to given word.private static int
applyUpperCasePattern
(int word) Returns a word where each ASCII uppercase byte has the highest bit set.private static long
applyUpperCasePattern
(long word) Returns a word where each ASCII uppercase byte has the highest bit set.static long
compilePattern
(byte byteToFind) Compiles given byte into a long pattern suitable for SWAR operations.static boolean
containsLowerCase
(int word) Returns true if the given word contains at least one ASCII lowercase byte.static boolean
containsLowerCase
(long word) Returns true if the given word contains at least one ASCII lowercase byte.static boolean
containsUpperCase
(int word) Returns true if the given word contains at least one ASCII uppercase byte.static boolean
containsUpperCase
(long word) Returns true if the given word contains at least one ASCII uppercase byte.static int
getIndex
(long word, boolean isBigEndian) Returns the index of the first occurrence of byte that specificied in the pattern.static int
toLowerCase
(int word) Returns a word with all bytes converted to lowercase ASCII.static long
toLowerCase
(long word) Returns a word with all bytes converted to lowercase ASCII.static int
toUpperCase
(int word) Returns a word with all bytes converted to uppercase ASCII.static long
toUpperCase
(long word) Returns a word with all bytes converted to uppercase ASCII.
-
Constructor Details
-
SWARUtil
private SWARUtil()
-
-
Method Details
-
compilePattern
public static long compilePattern(byte byteToFind) Compiles given byte into a long pattern suitable for SWAR operations. -
applyPattern
public static long applyPattern(long word, long pattern) Applies a compiled pattern to given word. Returns a word where each byte that matches the pattern has the highest bit set.- Parameters:
word
- the word to apply the pattern topattern
- the pattern to apply- Returns:
- a word where each byte that matches the pattern has the highest bit set
-
getIndex
public static int getIndex(long word, boolean isBigEndian) Returns the index of the first occurrence of byte that specificied in the pattern. If no pattern is found, returns 8.- Parameters:
word
- the return value ofapplyPattern(long, long)
isBigEndian
- if true, if given word is big endian if false, if given word is little endian- Returns:
- the index of the first occurrence of the specified pattern in the specified word. If no pattern is found, returns 8.
-
applyUpperCasePattern
private static long applyUpperCasePattern(long word) Returns a word where each ASCII uppercase byte has the highest bit set. -
applyUpperCasePattern
private static int applyUpperCasePattern(int word) Returns a word where each ASCII uppercase byte has the highest bit set. -
applyLowerCasePattern
private static long applyLowerCasePattern(long word) Returns a word where each ASCII lowercase byte has the highest bit set. -
applyLowerCasePattern
private static int applyLowerCasePattern(int word) Returns a word where each lowercase ASCII byte has the highest bit set. -
containsUpperCase
public static boolean containsUpperCase(long word) Returns true if the given word contains at least one ASCII uppercase byte. -
containsUpperCase
public static boolean containsUpperCase(int word) Returns true if the given word contains at least one ASCII uppercase byte. -
containsLowerCase
public static boolean containsLowerCase(long word) Returns true if the given word contains at least one ASCII lowercase byte. -
containsLowerCase
public static boolean containsLowerCase(int word) Returns true if the given word contains at least one ASCII lowercase byte. -
toLowerCase
public static long toLowerCase(long word) Returns a word with all bytes converted to lowercase ASCII. -
toLowerCase
public static int toLowerCase(int word) Returns a word with all bytes converted to lowercase ASCII. -
toUpperCase
public static long toUpperCase(long word) Returns a word with all bytes converted to uppercase ASCII. -
toUpperCase
public static int toUpperCase(int word) Returns a word with all bytes converted to uppercase ASCII.
-