Sha256: 87967ad2e0415f5ef3ad9b16ebf56b028269ffaa54899b1f5320cafced6bb1dd

Contents?: true

Size: 716 Bytes

Versions: 1

Compression:

Stored size: 716 Bytes

Contents

module Stackprofiler
  module Filter
    class CompressTree
      def filter root, frames
        depths = Hash.new {|h, k| h[k] = [] }
        root.each {|n| depths[n.node_depth].push n }
        depths.delete 0

        depths.keys.sort.reverse.each do |depth|
          nodes = depths[depth]
          nodes.each do |node|
            if node.out_degree == 1
              hash = node.content.dup
              hash[:addrs] = hash[:addrs] + node.first_child.content[:addrs]
              repl = Tree::TreeNode.new(node.name, hash)
              node.first_child.children.each {|n| repl << n }
              node.replace_with repl
            end
          end
        end
        root
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
stackprofiler-0.0.1 lib/stackprofiler/filters/compress_tree.rb