Pārlūkot izejas kodu

Reserve vec with certain size instead of capacity.

Jing Yang 5 gadi atpakaļ
vecāks
revīzija
ac213f6d53
1 mainītis faili ar 3 papildinājumiem un 3 dzēšanām
  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),
         };