Skip to content

Commit

Permalink
vdoc: cleanup node.v (#21250)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Apr 11, 2024
1 parent 6be2717 commit 6dc417e
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions vlib/v/doc/node.v
Expand Up @@ -6,10 +6,9 @@ pub const should_sort = os.getenv_opt('VDOC_SORT') or { 'true' }.bool()

pub fn (nodes []DocNode) find(symname string) !DocNode {
for node in nodes {
if node.name != symname {
continue
if node.name == symname {
return node
}
return node
}
return error('symbol not found')
}
Expand All @@ -29,15 +28,13 @@ pub fn (mut nodes []DocNode) sort_by_kind() {
}

fn compare_nodes_by_kind(a &DocNode, b &DocNode) int {
ak := int((*a).kind)
bk := int((*b).kind)
if ak < bk {
return -1
}
if ak > bk {
return 1
ak := int(a.kind)
bk := int(b.kind)
return match true {
ak < bk { -1 }
ak > bk { 1 }
else { 0 }
}
return 0
}

fn compare_nodes_by_name(a &DocNode, b &DocNode) int {
Expand All @@ -48,7 +45,7 @@ fn compare_nodes_by_name(a &DocNode, b &DocNode) int {

// arr() converts the map into an array of `DocNode`.
pub fn (cnts map[string]DocNode) arr() []DocNode {
mut contents := cnts.keys().map(cnts[it])
mut contents := cnts.values()
contents.sort_by_name()
contents.sort_by_kind()
return contents
Expand Down

0 comments on commit 6dc417e

Please sign in to comment.