Do not use regex to parse /proc/config.gz.
During boot, a compatibility check is performed and
/proc/config.gz is parsed. /proc/config.gz has
a well defined format:
# CONFIG_FOO is not set
CONFIG_BAR=y
with no trailing / leading spaces, spaces around
'=', or trailing comments. Using regex is slow
and unnecessary, hence a normal string search
is performed instead.
On the other hand, for assemble_vintf that needs to parse
android-base.cfg, because the file is maintained by
humans, free format is accepted, and regex is used.
Test: boots (boot time compat check passes)
Test: boot time regression no longer happens (~120ms vs. ~90ms)
Test: libvintf_test
Bug: 63537988
Change-Id: If6ab207d40459689386aaf40cd835effc5597886
diff --git a/assemble_vintf.cpp b/assemble_vintf.cpp
index 7683472..2752078 100644
--- a/assemble_vintf.cpp
+++ b/assemble_vintf.cpp
@@ -65,7 +65,7 @@
std::cerr << "File '" << path << "' does not exist or cannot be read." << std::endl;
return false;
}
- KernelConfigParser parser(true /* processComments */);
+ KernelConfigParser parser(true /* processComments */, true /* relaxedFormat */);
std::string content = read(ifs);
status_t err = parser.process(content.c_str(), content.size());
if (err != OK) {