linux: vmcoreinfo API: significantly improve the performance when validating each character, from O(n) to O(1).. where n is 100 chars long

This commit is contained in:
Gustavo Moreira
2025-01-30 18:44:18 +11:00
parent c2f2fc6b42
commit f6a22eed05
@@ -903,7 +903,8 @@ class VMCoreInfo(interfaces.configuration.VersionableInterface):
"""Converts the input VMCoreInfo data buffer into a dictionary"""
# Ensure the whole buffer is printable
if not all(char in string.printable.encode() for char in vmcoreinfo_data):
printable_bytes_set = set(string.printable.encode())
if not all(byte in printable_bytes_set for byte in vmcoreinfo_data):
# Abort, we are in the wrong place
return None