Commit a83b7619 authored by rjw's avatar rjw

iMore string usage optimizations. Got another 10% or so.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@753 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1b2d0ab2
2002-03-15 Richard Williamson <rjw@apple.com>
More string usage optimizations. Got another 10% or so.
* src/kdelibs/khtml/css/cssstyleselector.cpp: (checkPseudoState),
(khtml::applyRule):
* src/kdelibs/khtml/rendering/render_text.cpp: (RenderText::calcMinMaxWidth),
(RenderText::width):
2002-03-15 Darin Adler <darin@apple.com>
* src/kwq/KWQFontMetrics.mm: (QFontMetrics::descent): Oops, removed a - sign
......
2002-03-15 Richard Williamson <rjw@apple.com>
More string usage optimizations. Got another 10% or so.
* src/kdelibs/khtml/css/cssstyleselector.cpp: (checkPseudoState),
(khtml::applyRule):
* src/kdelibs/khtml/rendering/render_text.cpp: (RenderText::calcMinMaxWidth),
(RenderText::width):
2002-03-15 Darin Adler <darin@apple.com>
* src/kwq/KWQFontMetrics.mm: (QFontMetrics::descent): Oops, removed a - sign
......
2002-03-15 Richard Williamson <rjw@apple.com>
More string usage optimizations. Got another 10% or so.
* src/kdelibs/khtml/css/cssstyleselector.cpp: (checkPseudoState),
(khtml::applyRule):
* src/kdelibs/khtml/rendering/render_text.cpp: (RenderText::calcMinMaxWidth),
(RenderText::width):
2002-03-15 Darin Adler <darin@apple.com>
* src/kwq/KWQFontMetrics.mm: (QFontMetrics::descent): Oops, removed a - sign
......
......@@ -73,6 +73,13 @@ static int usedDynamicStates;
static int selectorDynamicState;
static CSSStyleSelector::Encodedurl *encodedurl;
#ifdef APPLE_CHANGES
#define OPTIMIZE_STRING_USAGE
#ifdef OPTIMIZE_STRING_USAGE
static CFMutableStringRef reuseableString = 0;
#endif
#endif
CSSStyleSelector::CSSStyleSelector(DocumentImpl * doc)
{
......@@ -456,7 +463,13 @@ static void checkPseudoState( DOM::ElementImpl *e )
pseudoState = PseudoNone;
return;
}
#if (defined(APPLE_CHANGES) && defined(OPTIMIZE_STRING_USAGE))
QString u = QString::gstring_toQString(&reuseableString, (UniChar *)(attr.unicode()), attr.length());
#else
// Pseudo elements. We need to check first child here. No dynamic pseudo
// elements for the moment
QString u = attr.string();
#endif
if ( !u.contains("://") ) {
if ( u[0] == '/' )
u = encodedurl->host + u;
......@@ -470,13 +483,6 @@ static void checkPseudoState( DOM::ElementImpl *e )
pseudoState = KHTMLFactory::vLinks()->contains( u ) ? PseudoVisited : PseudoLink;
}
#ifdef APPLE_CHANGES
#define OPTIMIZE_STRING_USAGE
#ifdef OPTIMIZE_STRING_USAGE
static CFMutableStringRef reuseableString = 0;
#endif
#endif
bool CSSStyleSelector::checkOneSelector(DOM::CSSSelector *sel, DOM::ElementImpl *e)
{
......@@ -2178,7 +2184,11 @@ void khtml::applyRule(khtml::RenderStyle *style, DOM::CSSProperty *prop, DOM::El
CSSPrimitiveValueImpl *val = static_cast<CSSPrimitiveValueImpl *>(item);
if(!val->primitiveType() == CSSPrimitiveValue::CSS_STRING) return;
DOMStringImpl *str = val->getStringValue();
#if (defined(APPLE_CHANGES) && defined(OPTIMIZE_STRING_USAGE))
QString face = QString::gstring_toQString(&reuseableString, (UniChar *)(str->s), str->l).lower();
#else
QString face = QConstString(str->s, str->l).string().lower();
#endif
// a languge tag is often added in braces at the end. Remove it.
face = face.replace(QRegExp(" \\(.*\\)$"), "");
//kdDebug(0) << "searching for face '" << face << "'" << endl;
......
......@@ -43,6 +43,14 @@
#define QT_ALLOC_QCHAR_VEC( N ) (QChar*) new char[ sizeof(QChar)*( N ) ]
#define QT_DELETE_QCHAR_VEC( P ) delete[] ((char*)( P ))
#ifdef APPLE_CHANGES
#define OPTIMIZE_STRING_USAGE
#ifdef OPTIMIZE_STRING_USAGE
static CFMutableStringRef reuseableString = 0;
#endif
#endif
using namespace khtml;
using namespace DOM;
......@@ -659,13 +667,6 @@ void RenderText::print( QPainter *p, int x, int y, int w, int h,
printObject(p, x, y, w, h, tx, ty);
}
#ifdef APPLE_CHANGES
#define OPTIMIZE_STRING_USAGE
#ifdef OPTIMIZE_STRING_USAGE
static CFMutableStringRef reuseableString = 0;
#endif
#endif
void RenderText::calcMinMaxWidth()
{
//kdDebug( 6040 ) << "Text::calcMinMaxWidth(): known=" << minMaxKnown() << endl;
......@@ -717,11 +718,7 @@ void RenderText::calcMinMaxWidth()
if(currMinWidth > m_minWidth) m_minWidth = currMinWidth;
currMinWidth = 0;
#if (defined(APPLE_CHANGES) && defined(OPTIMIZE_STRING_USAGE))
if (reuseableString == 0)
reuseableString = CFStringCreateMutableWithExternalCharactersNoCopy (kCFAllocatorDefault, (UniChar *)(str->s+i+wordlen), wordlen, wordlen, kCFAllocatorDefault);
else
CFStringSetExternalCharactersNoCopy (reuseableString, (UniChar *)(str->s+i+wordlen), 1, 1);
currMaxWidth += _fm._width(reuseableString);
currMaxWidth += _fm._width(QString::gstring_toCFString(&reuseableString, (UniChar *)(str->s+i+wordlen), 1));
#else
currMaxWidth += _fm.width( *(str->s+i+wordlen) );
#endif
......@@ -902,7 +899,11 @@ unsigned int RenderText::width(unsigned int from, unsigned int len, QFontMetrics
if( len == 1)
w = _fm->width( *(str->s+from) );
else
#if (defined(APPLE_CHANGES) && defined(OPTIMIZE_STRING_USAGE))
w = _fm->_width(QString::gstring_toCFString(&reuseableString, (UniChar *)(str->s+from), len));
#else
w = _fm->width(QConstString(str->s+from, len).string());
#endif
// ### add margins and support for RTL
......
......@@ -73,6 +73,13 @@ static int usedDynamicStates;
static int selectorDynamicState;
static CSSStyleSelector::Encodedurl *encodedurl;
#ifdef APPLE_CHANGES
#define OPTIMIZE_STRING_USAGE
#ifdef OPTIMIZE_STRING_USAGE
static CFMutableStringRef reuseableString = 0;
#endif
#endif
CSSStyleSelector::CSSStyleSelector(DocumentImpl * doc)
{
......@@ -456,7 +463,13 @@ static void checkPseudoState( DOM::ElementImpl *e )
pseudoState = PseudoNone;
return;
}
#if (defined(APPLE_CHANGES) && defined(OPTIMIZE_STRING_USAGE))
QString u = QString::gstring_toQString(&reuseableString, (UniChar *)(attr.unicode()), attr.length());
#else
// Pseudo elements. We need to check first child here. No dynamic pseudo
// elements for the moment
QString u = attr.string();
#endif
if ( !u.contains("://") ) {
if ( u[0] == '/' )
u = encodedurl->host + u;
......@@ -470,13 +483,6 @@ static void checkPseudoState( DOM::ElementImpl *e )
pseudoState = KHTMLFactory::vLinks()->contains( u ) ? PseudoVisited : PseudoLink;
}
#ifdef APPLE_CHANGES
#define OPTIMIZE_STRING_USAGE
#ifdef OPTIMIZE_STRING_USAGE
static CFMutableStringRef reuseableString = 0;
#endif
#endif
bool CSSStyleSelector::checkOneSelector(DOM::CSSSelector *sel, DOM::ElementImpl *e)
{
......@@ -2178,7 +2184,11 @@ void khtml::applyRule(khtml::RenderStyle *style, DOM::CSSProperty *prop, DOM::El
CSSPrimitiveValueImpl *val = static_cast<CSSPrimitiveValueImpl *>(item);
if(!val->primitiveType() == CSSPrimitiveValue::CSS_STRING) return;
DOMStringImpl *str = val->getStringValue();
#if (defined(APPLE_CHANGES) && defined(OPTIMIZE_STRING_USAGE))
QString face = QString::gstring_toQString(&reuseableString, (UniChar *)(str->s), str->l).lower();
#else
QString face = QConstString(str->s, str->l).string().lower();
#endif
// a languge tag is often added in braces at the end. Remove it.
face = face.replace(QRegExp(" \\(.*\\)$"), "");
//kdDebug(0) << "searching for face '" << face << "'" << endl;
......
......@@ -43,6 +43,14 @@
#define QT_ALLOC_QCHAR_VEC( N ) (QChar*) new char[ sizeof(QChar)*( N ) ]
#define QT_DELETE_QCHAR_VEC( P ) delete[] ((char*)( P ))
#ifdef APPLE_CHANGES
#define OPTIMIZE_STRING_USAGE
#ifdef OPTIMIZE_STRING_USAGE
static CFMutableStringRef reuseableString = 0;
#endif
#endif
using namespace khtml;
using namespace DOM;
......@@ -659,13 +667,6 @@ void RenderText::print( QPainter *p, int x, int y, int w, int h,
printObject(p, x, y, w, h, tx, ty);
}
#ifdef APPLE_CHANGES
#define OPTIMIZE_STRING_USAGE
#ifdef OPTIMIZE_STRING_USAGE
static CFMutableStringRef reuseableString = 0;
#endif
#endif
void RenderText::calcMinMaxWidth()
{
//kdDebug( 6040 ) << "Text::calcMinMaxWidth(): known=" << minMaxKnown() << endl;
......@@ -717,11 +718,7 @@ void RenderText::calcMinMaxWidth()
if(currMinWidth > m_minWidth) m_minWidth = currMinWidth;
currMinWidth = 0;
#if (defined(APPLE_CHANGES) && defined(OPTIMIZE_STRING_USAGE))
if (reuseableString == 0)
reuseableString = CFStringCreateMutableWithExternalCharactersNoCopy (kCFAllocatorDefault, (UniChar *)(str->s+i+wordlen), wordlen, wordlen, kCFAllocatorDefault);
else
CFStringSetExternalCharactersNoCopy (reuseableString, (UniChar *)(str->s+i+wordlen), 1, 1);
currMaxWidth += _fm._width(reuseableString);
currMaxWidth += _fm._width(QString::gstring_toCFString(&reuseableString, (UniChar *)(str->s+i+wordlen), 1));
#else
currMaxWidth += _fm.width( *(str->s+i+wordlen) );
#endif
......@@ -902,7 +899,11 @@ unsigned int RenderText::width(unsigned int from, unsigned int len, QFontMetrics
if( len == 1)
w = _fm->width( *(str->s+from) );
else
#if (defined(APPLE_CHANGES) && defined(OPTIMIZE_STRING_USAGE))
w = _fm->_width(QString::gstring_toCFString(&reuseableString, (UniChar *)(str->s+from), len));
#else
w = _fm->width(QConstString(str->s+from, len).string());
#endif
// ### add margins and support for RTL
......
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