ソースを参照

Reserve vec with certain size instead of capacity.

Jing Yang 5 年 前
コミット
ac213f6d53
1 ファイル変更3 行追加3 行削除
  1. 3 3
      src/lib.rs

+ 3 - 3
src/lib.rs

@@ -139,9 +139,9 @@ impl Raft {
             }],
             commit_index: 0,
             last_applied: 0,
-            next_index: Vec::with_capacity(peer_size),
-            match_index: Vec::with_capacity(peer_size),
-            current_step: Vec::with_capacity(peer_size),
+            next_index: vec![0; peer_size],
+            match_index: vec![0; peer_size],
+            current_step: vec![0; peer_size],
             state: State::Follower,
             leader_id: Peer(me),
         };