From 116b15887eda01f1ae39571a580c2496b6c7c506 Mon Sep 17 00:00:00 2001 From: Bram Gruneir Date: Mon, 18 Jul 2016 14:57:56 -0400 Subject: [PATCH] storage: only call Desc() if needed in queues It requires getting a lock, so we should avoid calling it unnecessarily. --- storage/queue.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/storage/queue.go b/storage/queue.go index 121e125529d4..3a021264a6fb 100644 --- a/storage/queue.go +++ b/storage/queue.go @@ -307,6 +307,9 @@ func (bq *baseQueue) MaybeAdd(repl *Replica, now hlc.Timestamp) { } func (bq *baseQueue) requiresSplit(cfg config.SystemConfig, repl *Replica) bool { + if bq.acceptsUnsplitRanges { + return false + } // If there's no store (as is the case in some narrow unit tests), or if // the store's split queue is disabled, the "required" split will never // come. In that case, pretend we don't require the split. @@ -314,7 +317,7 @@ func (bq *baseQueue) requiresSplit(cfg config.SystemConfig, repl *Replica) bool return false } desc := repl.Desc() - return !bq.acceptsUnsplitRanges && cfg.NeedsSplit(desc.StartKey, desc.EndKey) + return cfg.NeedsSplit(desc.StartKey, desc.EndKey) } // addInternal adds the replica the queue with specified priority. If the