Skip to content

Commit

Permalink
Merge pull request #55 from ArtemkaKun/v-reset-array-instead-of-alloc…
Browse files Browse the repository at this point in the history
…ate-new

V reset array instead of allocate new
  • Loading branch information
jinyus authored Oct 1, 2023
2 parents e6fc212 + cf3d731 commit 2983123
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions v/related.v
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ fn main() {
}

mut all_related_posts := []RelatedPosts{cap: posts.len}
mut tagged_post_count := []int{len: posts.len}

for i, post in posts {
// slower when preallocated
mut tagged_post_count := []int{len: posts.len, cap: posts.len}
for j in 0 .. tagged_post_count.len {
tagged_post_count[j] = 0
}

for tag in post.tags {
for post_index in tag_map[tag] {
Expand Down

0 comments on commit 2983123

Please sign in to comment.