adjacency-list: fix crash in equals operator

some minor code improvements

refs: #4705

Change-Id: I28805981a88a94c79f699956bb7e62a268d9ba49
diff --git a/src/adjacency-list.cpp b/src/adjacency-list.cpp
index 7fa3e6e..0cf8ff3 100644
--- a/src/adjacency-list.cpp
+++ b/src/adjacency-list.cpp
@@ -73,14 +73,15 @@
 bool
 AdjacencyList::operator==(const AdjacencyList& adl) const
 {
-  if (m_adjList.size() != adl.getAdjList().size()) {
+  auto theirList = adl.getAdjList();
+  if (m_adjList.size() != theirList.size()) {
     return false;
   }
 
-  std::set<Adjacent> ourList(m_adjList.cbegin(), m_adjList.cend());
-  std::set<Adjacent> theirList(adl.getAdjList().cbegin(), adl.getAdjList().cend());
+  std::set<Adjacent> ourSet(m_adjList.cbegin(), m_adjList.cend());
+  std::set<Adjacent> theirSet(theirList.cbegin(), theirList.cend());
 
-  return ourList == theirList;
+  return ourSet == theirSet;
 }
 
 bool