Commits

Michał Górny committed e63b67c

Use frozensets in *Cache.

Comments (0)

Files changed (1)

lib/flaggie/cache.py

 				for p in self.dbapi.xmatch('match-all', k):
 					flags.update(self._aux_parse(self.dbapi.aux_get(p, \
 							(self.aux_key,))[0]))
-				self.cache[k] = flags
+				self.cache[k] = frozenset(flags)
 			return self.cache[k]
 
 		def get_effective(self, k):
 			if k not in self.effective_cache:
-				flags = set()
 				pkgs = self.dbapi.xmatch('match-all', k)
 				if pkgs:
-					flags.update(self._aux_parse(self.dbapi.aux_get( \
-							best(pkgs), (self.aux_key,))[0]))
-				self.effective_cache[k] = flags
+					flags = self._aux_parse(self.dbapi.aux_get( \
+							best(pkgs), (self.aux_key,))[0])
+				else:
+					flags = ()
+				self.effective_cache[k] = frozenset(flags)
 			return self.effective_cache[k]
 
 	class FlagCache(DBAPICache):
 							if len(ll) > 1:
 								flags.add(ll[0])
 						f.close()
-				self.cache[None] = flags
+				self.cache[None] = frozenset(flags)
 
 			return self.cache[None]
 
 						pass
 					else:
 						for l in f:
-							if l.strip() and not l.startswith('#'):
-								kws.add(l.strip())
+							kw = l.strip()
+							if kw and not kw.startswith('#'):
+								kws.update((kw, '~' + kw))
 						f.close()
 
-				# testing keywords
-				for k in kws.copy():
-					kws.add('~%s' % k)
 				# and the ** special keyword
 				kws.add('**')
-				self.cache[None] = kws
+				self.cache[None] = frozenset(kws)
 
 			return self.cache[None]
 
 						lic.update(os.listdir(os.path.join(r, 'licenses')))
 					except OSError:
 						pass
-				self.cache[None] = lic
+				self.cache[None] = frozenset(lic)
 
 			return self.cache[None]
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.