Module: Skylight::Core::Util::AllocationFree Private
- Included in:
- Normalizers::RenderNormalizer
- Defined in:
- lib/skylight/core/util/allocation_free.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Helpers to reduce memory allocation
Instance Method Summary collapse
-
#array_find(array) {|item| ... } ⇒ Object
private
Find an item in an array without allocation.
Instance Method Details
#array_find(array) {|item| ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Find an item in an array without allocation.
return the found item or nil, if nothing found
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/skylight/core/util/allocation_free.rb', line 13 def array_find(array) i = 0 while i < array.size item = array[i] return item if yield item i += 1 end nil end |