rage_flip 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db5be08744369388bbc29752411e903e25ad018bcf024f49401f0181519b5642
4
- data.tar.gz: b9117dc053c098d74625f71cdbf32cd4ef50542fe2c5d315f93d0f37f584af91
3
+ metadata.gz: be851a607c8ae9594a47bc2168081177d480fed2ea27716a3f6348177fe4f388
4
+ data.tar.gz: 5b50d3cb304662ecf0aa34b88242b75637fc79d5de4b4d0e5dda41ac7ea5b102
5
5
  SHA512:
6
- metadata.gz: ed8150e74a80e424f5c97c153bf349a1a25261c67af53c26b2cce71849e31406ddbf8db651fb6532d16ffd80a71cb9a9ef9e7c5e1e154709ad3f25c716980b5f
7
- data.tar.gz: 2bc6ba4473e0a81a8a9dbf86e18921d04d693bf3fcc566297ee477e3d7fc5287ceb8dbe9e55c6b7615ba620f0b890d5c9e6858c8fe82d19e7722a71ab6261c91
6
+ metadata.gz: 1537cd58af3de8fbfc5dc434c74c07dab793c2d2a8ce1a74607fe672dc31696a71295232dadff2ca70c2ff4240de47ee659d23c45abf8280d740069b0b308f3b
7
+ data.tar.gz: 7ebdd3ab4cc36f77d17def87cf0c47dc0fe2d9b1f18293808c64ac785c32351c48bd9d2f54fe425f290f0a97f98caab67c76824f56051a1f0e221fbaffc51a07
@@ -1911,6 +1911,18 @@ module RageFlip
1911
1911
  def self.refresh_emotes
1912
1912
  @all_emotes = nil
1913
1913
  @emoji_only_emotes = nil
1914
+ @emote_by_first_char = nil
1915
+ @compound_memo = nil
1916
+ end
1917
+
1918
+ def self.emote_by_first_char
1919
+ @emote_by_first_char ||= emoji_only_emotes.each_with_object(Hash.new { |h, k| h[k] = [] }) do |(name, value), h|
1920
+ h[name[0]] << [name, value]
1921
+ end
1922
+ end
1923
+
1924
+ def self.compound_memo
1925
+ @compound_memo ||= {}
1914
1926
  end
1915
1927
 
1916
1928
  # Check if an emote value contains only emoji (no ASCII art or text)
@@ -1941,22 +1953,21 @@ module RageFlip
1941
1953
  end
1942
1954
 
1943
1955
  # Find a valid combination of emoji-only emotes that match the compound name
1944
- def self.find_emote_combination(name, start = 0, memo = {})
1956
+ def self.find_emote_combination(name, start = 0, memo = compound_memo)
1945
1957
  return [] if start >= name.length
1946
1958
  return memo[[name, start]] if memo.key?([name, start])
1947
1959
 
1948
- # Try each emoji-only emote starting at this position
1949
- emoji_only_emotes.each do |emote_name, emote_value|
1950
- next unless name[start..-1].start_with?(emote_name)
1960
+ # Only check emotes whose name starts with the same character — avoids O(n) scan
1961
+ candidates = emote_by_first_char[name[start]] || []
1962
+ candidates.each do |emote_name, emote_value|
1963
+ next unless name[start..].start_with?(emote_name)
1951
1964
 
1952
1965
  rest_start = start + emote_name.length
1953
1966
  if rest_start >= name.length
1954
- # We've matched the entire string
1955
1967
  memo[[name, start]] = [emote_value]
1956
1968
  return [emote_value]
1957
1969
  end
1958
1970
 
1959
- # Try to match the rest
1960
1971
  rest = find_emote_combination(name, rest_start, memo)
1961
1972
  if rest
1962
1973
  result = [emote_value] + rest
@@ -1,3 +1,3 @@
1
1
  module RageFlip
2
- VERSION = "2.3.0"
2
+ VERSION = "2.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rage_flip
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Powell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-05-13 00:00:00.000000000 Z
11
+ date: 2026-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec