Class SWARUtil

java.lang.Object
io.netty.util.internal.SWARUtil

public final class SWARUtil extends Object
Utility class for SWAR (SIMD within a register) operations.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private static int
    Returns a word where each lowercase ASCII byte has the highest bit set.
    private static long
    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
    Returns a word where each ASCII uppercase byte has the highest bit set.
    private static long
    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
    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
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 to
      pattern - 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 of applyPattern(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.