1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 23:42:31 +03:00

Compute the count eagerly.

This commit is contained in:
Rob Rix 2015-10-28 18:22:53 -04:00
parent 8d4bc19dc1
commit e2e37a011d

View File

@ -14,17 +14,17 @@ extension TSNode {
}
var children: AnyRandomAccessCollection<TSNode> {
return AnyRandomAccessCollection(ChildrenCollection(node: self, count: ts_node_child_count, child: ts_node_child))
return AnyRandomAccessCollection(ChildrenCollection(node: self, count: ts_node_child_count(self), child: ts_node_child))
}
var namedChildren: AnyRandomAccessCollection<TSNode> {
return AnyRandomAccessCollection(ChildrenCollection(node: self, count: ts_node_named_child_count, child: ts_node_named_child))
return AnyRandomAccessCollection(ChildrenCollection(node: self, count: ts_node_named_child_count(self), child: ts_node_named_child))
}
private struct ChildrenCollection: CollectionType {
let node: TSNode
let count: TSNode -> Int
let count: Int
let child: (TSNode, Int) -> TSNode
subscript (index: Int) -> TSNode {
@ -33,7 +33,7 @@ extension TSNode {
let startIndex = 0
var endIndex: Int {
return count(node)
return count
}
}
}