Remove line number from rtc::Location
Concatenating __FILE__ with __LINE__ prevents the compiler from aliasing strings within the same file, contributing ~30KB of .text bloat. Chrome already omits from the file number from its Location type so it doesn't seem to be a big loss. Bug: b/145168048 Change-Id: I000bfdf43f4eb90f8b63ed017b08c1b5a7a84a6d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/160744 Commit-Queue: Steve Anton <steveanton@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29994}
This commit is contained in:
@ -27,31 +27,32 @@ class RTC_EXPORT Location {
|
||||
// Constructor should be called with a long-lived char*, such as __FILE__.
|
||||
// It assumes the provided value will persist as a global constant, and it
|
||||
// will not make a copy of it.
|
||||
//
|
||||
// TODO(deadbeef): Tracing is currently limited to 2 arguments, which is
|
||||
// why the file name and line number are combined into one argument.
|
||||
//
|
||||
// Once TracingV2 is available, separate the file name and line number.
|
||||
Location(const char* function_name, const char* file_and_line);
|
||||
Location();
|
||||
Location(const Location& other);
|
||||
Location& operator=(const Location& other);
|
||||
Location(const char* function_name, const char* file_name, int line_number)
|
||||
: function_name_(function_name),
|
||||
file_name_(file_name),
|
||||
line_number_(line_number) {}
|
||||
Location() = default;
|
||||
|
||||
const char* function_name() const { return function_name_; }
|
||||
const char* file_and_line() const { return file_and_line_; }
|
||||
const char* file_name() const { return file_name_; }
|
||||
int line_number() const { return line_number_; }
|
||||
// TODO(steveanton): Remove once all downstream users have been updated to use
|
||||
// |file_name()| and/or |line_number()|.
|
||||
const char* file_and_line() const { return file_name_; }
|
||||
|
||||
std::string ToString() const;
|
||||
|
||||
private:
|
||||
const char* function_name_;
|
||||
const char* file_and_line_;
|
||||
const char* function_name_ = "Unknown";
|
||||
const char* file_name_ = "Unknown";
|
||||
int line_number_ = -1;
|
||||
};
|
||||
|
||||
// Define a macro to record the current source location.
|
||||
#define RTC_FROM_HERE RTC_FROM_HERE_WITH_FUNCTION(__FUNCTION__)
|
||||
|
||||
#define RTC_FROM_HERE_WITH_FUNCTION(function_name) \
|
||||
::rtc::Location(function_name, __FILE__ ":" STRINGIZE(__LINE__))
|
||||
::rtc::Location(function_name, __FILE__, __LINE__)
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
|
||||
Reference in New Issue
Block a user