Unverified Commit b10e5198 authored by Woosuk Kwon's avatar Woosuk Kwon Committed by GitHub
Browse files

[V1][Minor] Optimize get_cached_block (#16135)

parent 9bde5ba1
...@@ -67,11 +67,11 @@ class BlockPool: ...@@ -67,11 +67,11 @@ class BlockPool:
Returns: Returns:
The cached block if it exists, or None. The cached block if it exists, or None.
""" """
if block_hash in self.cached_block_hash_to_block: cached_blocks = self.cached_block_hash_to_block.get(block_hash)
first_block_id = list( if not cached_blocks:
self.cached_block_hash_to_block[block_hash].keys())[0] return None
return self.cached_block_hash_to_block[block_hash][first_block_id] first_block_id = next(iter(cached_blocks))
return None return cached_blocks[first_block_id]
def cache_full_blocks( def cache_full_blocks(
self, self,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment