Commit 66253d12 authored by fs@opera.com's avatar fs@opera.com

Reduce type-impedance for ExceptionMessages::failedTo* functions

These functions are always called with string literals, so having the
functions accept Strings means all callers have to perform implicit
conversions.
By modifying the signatures to use 'const char*' for these cases, these
conversion can be avoided (in the callers) and only be performed in the
functions themselves.
This reduces code size by ~70kB (Linux, x86-64, gcc-4.8.2).

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

git-svn-id: svn://svn.chromium.org/blink/trunk@170304 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent d67b2ea5
......@@ -36,52 +36,52 @@
namespace WebCore {
String ExceptionMessages::failedToConstruct(const String& type, const String& detail)
String ExceptionMessages::failedToConstruct(const char* type, const String& detail)
{
return "Failed to construct '" + type + (!detail.isEmpty() ? String("': " + detail) : String("'"));
return "Failed to construct '" + String(type) + (!detail.isEmpty() ? String("': " + detail) : String("'"));
}
String ExceptionMessages::failedToEnumerate(const String& type, const String& detail)
String ExceptionMessages::failedToEnumerate(const char* type, const String& detail)
{
return "Failed to enumerate the properties of '" + type + (!detail.isEmpty() ? String("': " + detail) : String("'"));
return "Failed to enumerate the properties of '" + String(type) + (!detail.isEmpty() ? String("': " + detail) : String("'"));
}
String ExceptionMessages::failedToExecute(const String& method, const String& type, const String& detail)
String ExceptionMessages::failedToExecute(const char* method, const char* type, const String& detail)
{
return "Failed to execute '" + method + "' on '" + type + (!detail.isEmpty() ? String("': " + detail) : String("'"));
return "Failed to execute '" + String(method) + "' on '" + String(type) + (!detail.isEmpty() ? String("': " + detail) : String("'"));
}
String ExceptionMessages::failedToGet(const String& property, const String& type, const String& detail)
String ExceptionMessages::failedToGet(const char* property, const char* type, const String& detail)
{
return "Failed to read the '" + property + "' property from '" + type + "': " + detail;
return "Failed to read the '" + String(property) + "' property from '" + String(type) + "': " + detail;
}
String ExceptionMessages::failedToSet(const String& property, const String& type, const String& detail)
String ExceptionMessages::failedToSet(const char* property, const char* type, const String& detail)
{
return "Failed to set the '" + property + "' property on '" + type + "': " + detail;
return "Failed to set the '" + String(property) + "' property on '" + String(type) + "': " + detail;
}
String ExceptionMessages::failedToDelete(const String& property, const String& type, const String& detail)
String ExceptionMessages::failedToDelete(const char* property, const char* type, const String& detail)
{
return "Failed to delete the '" + property + "' property from '" + type + "': " + detail;
return "Failed to delete the '" + String(property) + "' property from '" + String(type) + "': " + detail;
}
String ExceptionMessages::failedToGetIndexed(const String& type, const String& detail)
String ExceptionMessages::failedToGetIndexed(const char* type, const String& detail)
{
return "Failed to read an indexed property from '" + type + "': " + detail;
return "Failed to read an indexed property from '" + String(type) + "': " + detail;
}
String ExceptionMessages::failedToSetIndexed(const String& type, const String& detail)
String ExceptionMessages::failedToSetIndexed(const char* type, const String& detail)
{
return "Failed to set an indexed property on '" + type + "': " + detail;
return "Failed to set an indexed property on '" + String(type) + "': " + detail;
}
String ExceptionMessages::failedToDeleteIndexed(const String& type, const String& detail)
String ExceptionMessages::failedToDeleteIndexed(const char* type, const String& detail)
{
return "Failed to delete an indexed property from '" + type + "': " + detail;
return "Failed to delete an indexed property from '" + String(type) + "': " + detail;
}
String ExceptionMessages::constructorNotCallableAsFunction(const String& type)
String ExceptionMessages::constructorNotCallableAsFunction(const char* type)
{
return failedToConstruct(type, "Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
}
......
......@@ -47,17 +47,17 @@ public:
};
static String argumentNullOrIncorrectType(int argumentIndex, const String& expectedType);
static String constructorNotCallableAsFunction(const String& type);
static String failedToConstruct(const String& type, const String& detail);
static String failedToEnumerate(const String& type, const String& detail);
static String failedToExecute(const String& method, const String& type, const String& detail);
static String failedToGet(const String& property, const String& type, const String& detail);
static String failedToSet(const String& property, const String& type, const String& detail);
static String failedToDelete(const String& property, const String& type, const String& detail);
static String failedToGetIndexed(const String& type, const String& detail);
static String failedToSetIndexed(const String& type, const String& detail);
static String failedToDeleteIndexed(const String& type, const String& detail);
static String constructorNotCallableAsFunction(const char* type);
static String failedToConstruct(const char* type, const String& detail);
static String failedToEnumerate(const char* type, const String& detail);
static String failedToExecute(const char* method, const char* type, const String& detail);
static String failedToGet(const char* property, const char* type, const String& detail);
static String failedToSet(const char* property, const char* type, const String& detail);
static String failedToDelete(const char* property, const char* type, const String& detail);
static String failedToGetIndexed(const char* type, const String& detail);
static String failedToSetIndexed(const char* type, const String& detail);
static String failedToDeleteIndexed(const char* type, const String& detail);
template <typename NumType>
static String formatNumber(NumType number)
......
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