Module: HeapInfo::Ext::String::InstanceMethods
- Defined in:
- lib/heapinfo/ext/string.rb
Overview
Methods to be mixed into String
Instance Method Summary collapse
-
#to_chunk(bits: 64, base: 0) ⇒ HeapInfo::Chunk
Convert string to a Chunk.
-
#to_chunks(bits: 64, base: 0) ⇒ HeapInfo::Chunks
Convert string to array of Chunk.
Instance Method Details
#to_chunk(bits: 64, base: 0) ⇒ HeapInfo::Chunk
Convert string to a Chunk.
15 16 17 18 19 |
# File 'lib/heapinfo/ext/string.rb', line 15 def to_chunk(bits: 64, base: 0) size_t = bits / 8 dumper = ->(addr, len) { self[addr - base, len] } Chunk.new(size_t, base, dumper) end |
#to_chunks(bits: 64, base: 0) ⇒ HeapInfo::Chunks
Convert string to array of Chunk.
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/heapinfo/ext/string.rb', line 25 def to_chunks(bits: 64, base: 0) size_t = bits / 8 chunks = Chunks.new cur = 0 while cur + size_t * 2 <= length now_chunk = self[cur, size_t * 2].to_chunk sz = now_chunk.size chunks << self[cur, sz + 1].to_chunk(bits: bits, base: base + cur) # +1 for dump prev_inuse cur += sz end chunks end |