Commit 6a4eb0c4 authored by bratell's avatar bratell Committed by Commit bot

Make the GPU feature info code more compact.

AddExtensionString is called quite a lot, always with a constant
string literal, which makes it a bit unnecessary to convert the
argument to a std::string before every function call.

This small change cuts away 7 KB of the machine code:

Total change: -7208 bytes
=========================
  1 added, totalling +559 bytes across 1 sources
  1 removed, totalling -471 bytes across 1 sources
  1 shrunk, for a net change of -7296 bytes (25422 bytes before, 18126 bytes after) across 1 sources
  267984 unchanged, totalling 50299073 bytes
Per-source Analysis:

--------------------------------------------------------------------------------------------------------------------
 -7208 - Source: /home/bratell/src/chromium/src/gpu/command_buffer/service/feature_info.cc - (gained 559, lost 7767)
--------------------------------------------------------------------------------------------------------------------
  New symbols:
       +559: gpu::gles2::FeatureInfo::AddExtensionString(char const*) type=t, size=559 bytes
  Removed symbols:
       -471: gpu::gles2::FeatureInfo::AddExtensionString(std::string const&) type=t, size=471 bytes
  Shrunk symbols:
      -7296: gpu::gles2::FeatureInfo::InitializeFeatures() type=t, (was 25422 bytes, now 18126 bytes)

BUG=

Review URL: https://codereview.chromium.org/571073003

Cr-Commit-Position: refs/heads/master@{#296785}
parent d649a3b3
...@@ -860,7 +860,8 @@ void FeatureInfo::InitializeFeatures() { ...@@ -860,7 +860,8 @@ void FeatureInfo::InitializeFeatures() {
} }
} }
void FeatureInfo::AddExtensionString(const std::string& str) { void FeatureInfo::AddExtensionString(const char* s) {
std::string str(s);
size_t pos = extensions_.find(str); size_t pos = extensions_.find(str);
while (pos != std::string::npos && while (pos != std::string::npos &&
pos + str.length() < extensions_.length() && pos + str.length() < extensions_.length() &&
......
...@@ -126,7 +126,7 @@ class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> { ...@@ -126,7 +126,7 @@ class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> {
~FeatureInfo(); ~FeatureInfo();
void AddExtensionString(const std::string& str); void AddExtensionString(const char* s);
void InitializeBasicState(const base::CommandLine& command_line); void InitializeBasicState(const base::CommandLine& command_line);
void InitializeFeatures(); void InitializeFeatures();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment