Bug 226439. Some small conversion to use EqualsLiteral to see effect on code size, r+sr=dbaron. Additionally, some comments to clarify that EqualsLiteral is only for actual literals, and to properly credit Corey Kosak who showed me the template trick. Also re-enabled the template for MSVC++ 7.1, which can apparently handle it.
This commit is contained in:
@@ -4394,7 +4394,7 @@ NS_IMETHODIMP PresShell::GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocation
|
||||
if (element) {
|
||||
NS_NAMED_LITERAL_STRING(xlinkNS,"http://www.w3.org/1999/xlink");
|
||||
element->GetAttributeNS(xlinkNS,NS_LITERAL_STRING("type"),xlinkType);
|
||||
if (xlinkType.Equals(NS_LITERAL_STRING("simple"))) {
|
||||
if (xlinkType.EqualsLiteral("simple")) {
|
||||
element->GetAttributeNS(xlinkNS,NS_LITERAL_STRING("href"),anchorText);
|
||||
if (!anchorText.IsEmpty()) {
|
||||
// Resolve the full URI using baseURI property
|
||||
|
||||
@@ -2639,9 +2639,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result)
|
||||
if (charset.IsEmpty()) return NS_OK;
|
||||
|
||||
// common charsets and those not requiring conversion first
|
||||
if (charset == NS_LITERAL_CSTRING("us-acsii")) {
|
||||
if (charset.EqualsLiteral("us-ascii")) {
|
||||
*result = PL_strdup("US_ASCII");
|
||||
} else if (charset == NS_LITERAL_CSTRING("ISO-8859-1") ||
|
||||
} else if (charset.EqualsLiteral("ISO-8859-1") ||
|
||||
!nsCRT::strncmp(PromiseFlatCString(charset).get(), "UTF", 3)) {
|
||||
*result = ToNewCString(charset);
|
||||
} else {
|
||||
|
||||
@@ -2639,9 +2639,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetDocumentEncoding(const char* *result)
|
||||
if (charset.IsEmpty()) return NS_OK;
|
||||
|
||||
// common charsets and those not requiring conversion first
|
||||
if (charset == NS_LITERAL_CSTRING("us-acsii")) {
|
||||
if (charset.EqualsLiteral("us-ascii")) {
|
||||
*result = PL_strdup("US_ASCII");
|
||||
} else if (charset == NS_LITERAL_CSTRING("ISO-8859-1") ||
|
||||
} else if (charset.EqualsLiteral("ISO-8859-1") ||
|
||||
!nsCRT::strncmp(PromiseFlatCString(charset).get(), "UTF", 3)) {
|
||||
*result = ToNewCString(charset);
|
||||
} else {
|
||||
|
||||
@@ -4394,7 +4394,7 @@ NS_IMETHODIMP PresShell::GetLinkLocation(nsIDOMNode* aNode, nsAString& aLocation
|
||||
if (element) {
|
||||
NS_NAMED_LITERAL_STRING(xlinkNS,"http://www.w3.org/1999/xlink");
|
||||
element->GetAttributeNS(xlinkNS,NS_LITERAL_STRING("type"),xlinkType);
|
||||
if (xlinkType.Equals(NS_LITERAL_STRING("simple"))) {
|
||||
if (xlinkType.EqualsLiteral("simple")) {
|
||||
element->GetAttributeNS(xlinkNS,NS_LITERAL_STRING("href"),anchorText);
|
||||
if (!anchorText.IsEmpty()) {
|
||||
// Resolve the full URI using baseURI property
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
// If some platform(s) can't handle our template that matches literal strings,
|
||||
// then we'll disable it on those platforms.
|
||||
#if !defined(NS_DISABLE_LITERAL_TEMPLATE) && defined(_MSC_VER)
|
||||
#if !defined(NS_DISABLE_LITERAL_TEMPLATE) && (defined(_MSC_VER) && _MSC_VER < 1310)
|
||||
#define NS_DISABLE_LITERAL_TEMPLATE
|
||||
#endif
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
// If some platform(s) can't handle our template that matches literal strings,
|
||||
// then we'll disable it on those platforms.
|
||||
#if !defined(NS_DISABLE_LITERAL_TEMPLATE) && defined(_MSC_VER)
|
||||
#if !defined(NS_DISABLE_LITERAL_TEMPLATE) && (defined(_MSC_VER) && _MSC_VER < 1310)
|
||||
#define NS_DISABLE_LITERAL_TEMPLATE
|
||||
#endif
|
||||
|
||||
|
||||
@@ -202,6 +202,11 @@ class nsTAString_CharT
|
||||
* wide strings.
|
||||
*/
|
||||
NS_COM PRBool EqualsASCII( const char* data, size_type len ) const;
|
||||
// EqualsLiteral must ONLY be applied to an actual literal string.
|
||||
// Do not attempt to use it with a regular char* pointer, or with a char
|
||||
// array variable.
|
||||
// The template trick to acquire the array length at compile time without
|
||||
// using a macro is due to Corey Kosak, with much thanks.
|
||||
#ifdef NS_DISABLE_LITERAL_TEMPLATE
|
||||
inline PRBool EqualsLiteral( const char* str ) const
|
||||
{
|
||||
|
||||
@@ -216,6 +216,11 @@ class nsTSubstring_CharT : public nsTAString_CharT
|
||||
NS_COM PRBool Equals( const char_type* data, const comparator_type& comp ) const;
|
||||
|
||||
NS_COM PRBool EqualsASCII( const char* data, size_type len ) const;
|
||||
// EqualsLiteral must ONLY be applied to an actual literal string.
|
||||
// Do not attempt to use it with a regular char* pointer, or with a char
|
||||
// array variable.
|
||||
// The template trick to acquire the array length at compile time without
|
||||
// using a macro is due to Corey Kosak, with much thanks.
|
||||
#ifdef NS_DISABLE_LITERAL_TEMPLATE
|
||||
inline PRBool EqualsLiteral( const char* str ) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user