Commit d3bae4a0 authored by Daniel Latypov's avatar Daniel Latypov Committed by Shuah Khan
Browse files

kunit: tool: simplify kconfig is_subset_of() logic



Don't use an O(nm) algorithm* and make it more readable by using a dict.

*Most obviously, it does a nested for-loop over the entire other config.
A bit more subtle, it calls .entries(), which constructs a set from the
list for _every_ outer iteration.

Signed-off-by: default avatarDaniel Latypov <dlatypov@google.com>
Reviewed-by: default avatarDavid Gow <davidgow@google.com>
Tested-by: default avatarBrendan Higgins <brendanhiggins@google.com>
Acked-by: default avatarBrendan Higgins <brendanhiggins@google.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent cd4a9bc8
Loading
Loading
Loading
Loading
+6 −7
Original line number Diff line number Diff line
@@ -41,15 +41,14 @@ class Kconfig(object):
		self._entries.append(entry)

	def is_subset_of(self, other: 'Kconfig') -> bool:
		other_dict = {e.name: e.value for e in other.entries()}
		for a in self.entries():
			found = False
			for b in other.entries():
				if a.name != b.name:
			b = other_dict.get(a.name)
			if b is None:
				if a.value == 'n':
					continue
				if a.value != b.value:
				return False
				found = True
			if a.value != 'n' and found == False:
			elif a.value != b:
				return False
		return True