• C
    Add support for multiple encodings in String.blank? · 7b44ffa2
    Cory Gwin @gwincr11 提交于
    Motivation:
      - When strings are encoded with `.encode("UTF-16LE")` `.blank?` throws
      an `Encoding::CompatibilityError` exception.
      - We tested multiple implementation to see what the fastest
      implementation was, rescueing the execption seems to be the fastest
      option we could find.
    
    Related Issues:
      - #28953
    
    Changes:
      - Add a rescue to catch the exception.
      - Added a `Concurrent::Map` to store a cache of encoded regex objects
      for requested encoding types.
      - Use the new `Concurrent::Map` cache to return the correct regex for
      the string being checked.
    7b44ffa2
blank.rb 3.0 KB