Rename INIT_FEATURE_NAMES to INIT_FEATURE_NAME_TO_VAL as we're about to gain a
inverse mapping of the same thing.
Use dict.items() unconditionally. iteritems() is a marginal perf optimsiation
for Python2 only, and simply not worth the effort on a script this small.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
{NULL, 0, NA, CPUID_REG_INV, 0, 0}
};
- static const struct feature_name features[] = INIT_FEATURE_NAMES;
+ static const struct feature_name features[] = INIT_FEATURE_NAME_TO_VAL;
/*
* NB: if we switch to using a cpu_policy derived object instead of a
* libxl_cpuid_policy_list we could get rid of the featureset -> cpuid leaf
static const struct feature_name {
const char *name;
unsigned int bit;
-} feature_names[] __initconstrel = INIT_FEATURE_NAMES;
+} feature_names[] __initconstrel = INIT_FEATURE_NAME_TO_VAL;
/*
* Parse a list of cpuid feature names -> bool, calling the callback for any
state.output.write(
"""}
-#define INIT_FEATURE_NAMES { \\
+#define INIT_FEATURE_NAME_TO_VAL { \\
""")
- try:
- _tmp = state.values.iteritems()
- except AttributeError:
- _tmp = state.values.items()
-
- for name, bit in sorted(_tmp):
+ for name, bit in sorted(state.values.items()):
state.output.write(
' { "%s", %sU },\\\n' % (name, bit)
)