message: perf: Speed up fetch collect
diff: @@ -131,16 +131,6 @@ impl BlockFetcher {
  let mut fetch = Vec::with_capacity(count);
  let mut start = fixed_last_common_header.number() + 1;
  - // Judge whether we should fetch the target block, neither stored nor in-flighted
  - let mut should_fetch = |block_hash| {
  - // NOTE: Filtering `BLOCK_STORED` but not `BLOCK_RECEIVED`, is for avoiding
  - // stopping synchronization even when orphan_pool maintains dirty items by bugs.
  - let stored = self
  - .active_chain
  - .contains_block_status(&block_hash, BlockStatus::BLOCK_STORED);
  - !stored && inflight.insert(self.peer, block_hash)
  - };
  -
  while fetch.len() < count && start <= best_known_header.number() {
  let span = min(
  best_known_header.number() - start + 1,
  @@ -151,9 +141,21 @@ impl BlockFetcher {
  let mut header = self
  .active_chain
  .get_ancestor(&best_known_header.hash(), start + span - 1)?;
  +
  + // Judge whether we should fetch the target block, neither stored nor in-flighted
  for _ in 0..span {
  let parent_hash = header.parent_hash();
  - if should_fetch(header.hash()) {
  + let hash = header.hash();
  + // NOTE: Filtering `BLOCK_STORED` but not `BLOCK_RECEIVED`, is for avoiding
  + // stopping synchronization even when orphan_pool maintains dirty items by bugs.
  + let stored = self
  + .active_chain
  + .contains_block_status(&hash, BlockStatus::BLOCK_STORED);
  + if stored {
  + // If the block is stored, its ancestor must on store
  + // So we can skip the search of this space directly
  + break;
  + } else if inflight.insert(self.peer, hash) {
  fetch.push(header)
  }
  