Reduce inline code size for CHECK() on Android builds.
Create a separate LogMessage constructor for CHECK() which includes
the "Check failed: ..." message and thus trims a function call from
the inline code. This also allows to fold "Check failed: " into a
single string instead of having one "Check failed: foo. " string per
call site.
Saves 74k from libchrome_public.so (27k from ChromePublic.apk).
For the record: PCHECK() doesn't seems to be used in the Android part
of the code, thus there's no need to optimize it.
BUG=484684
Review URL: https://codereview.chromium.org/1232463008
Cr-Commit-Position: refs/heads/master@{#338453}
diff --git a/base/logging.cc b/base/logging.cc
index 71528ad3f..559cb083 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -521,6 +521,12 @@
Init(file, line);
}
+LogMessage::LogMessage(const char* file, int line, const char* condition)
+ : severity_(LOG_FATAL), file_(file), line_(line) {
+ Init(file, line);
+ stream_ << "Check failed: " << condition << ". ";
+}
+
LogMessage::LogMessage(const char* file, int line, std::string* result)
: severity_(LOG_FATAL), file_(file), line_(line) {
Init(file, line);