[webkit-changes] cvs commit: WebCore/khtml/dom dom_string.cpp
dom_string.h
Eric
eseidel at opensource.apple.com
Fri Dec 16 14:26:12 PST 2005
eseidel 05/12/16 14:26:12
Modified: . ChangeLog
khtml/dom dom_string.cpp dom_string.h
Log:
Bug #: 6106
Submitted by: eseidel
Reviewed by: darin
DOMString should hold its impl in a RefPtr
http://bugzilla.opendarwin.org/show_bug.cgi?id=6106
I also cleaned up spacing in dom_string.cpp
No tests needed (no functionality changes).
* khtml/dom/dom_string.cpp:
(DOM::DOMString::DOMString):
(DOM::DOMString::operator += ):
(DOM::DOMString::insert):
(DOM::DOMString::operator []):
(DOM::DOMString::find):
(DOM::DOMString::length):
(DOM::DOMString::truncate):
(DOM::DOMString::remove):
(DOM::DOMString::split):
(DOM::DOMString::lower):
(DOM::DOMString::upper):
(DOM::DOMString::percentage):
(DOM::DOMString::unicode):
(DOM::DOMString::qstring):
(DOM::DOMString::toInt):
(DOM::DOMString::copy):
(DOM::strcasecmp):
(DOM::DOMString::toCoordsArray):
(DOM::DOMString::toLengthArray):
(DOM::operator==):
* khtml/dom/dom_string.h:
(DOM::DOMString::DOMString):
(DOM::DOMString::impl):
Revision Changes Path
1.554 +36 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.553
retrieving revision 1.554
diff -u -r1.553 -r1.554
--- ChangeLog 16 Dec 2005 21:43:41 -0000 1.553
+++ ChangeLog 16 Dec 2005 22:26:07 -0000 1.554
@@ -2,6 +2,42 @@
Reviewed by darin.
+ DOMString should hold its impl in a RefPtr
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=6106
+ I also cleaned up spacing in dom_string.cpp
+ No tests needed (no functionality changes).
+
+ * khtml/dom/dom_string.cpp:
+ (DOM::DOMString::DOMString):
+ (DOM::DOMString::operator += ):
+ (DOM::DOMString::insert):
+ (DOM::DOMString::operator []):
+ (DOM::DOMString::find):
+ (DOM::DOMString::length):
+ (DOM::DOMString::truncate):
+ (DOM::DOMString::remove):
+ (DOM::DOMString::split):
+ (DOM::DOMString::lower):
+ (DOM::DOMString::upper):
+ (DOM::DOMString::percentage):
+ (DOM::DOMString::unicode):
+ (DOM::DOMString::qstring):
+ (DOM::DOMString::toInt):
+ (DOM::DOMString::copy):
+ (DOM::strcasecmp):
+ (DOM::DOMString::toCoordsArray):
+ (DOM::DOMString::toLengthArray):
+ (DOM::operator==):
+ * khtml/dom/dom_string.h:
+ (DOM::DOMString::DOMString):
+ (DOM::DOMString::impl):
+
+2005-12-16 Eric Seidel <eseidel at apple.com>
+
+ Reviewed by darin.
+
+ XSLTProcessorImpl should use RefPtr instead of manual ref/deref
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=6110
No test cases needed (no functionality changes).
* khtml/xsl/xsl_stylesheetimpl.cpp:
1.24 +56 -83 WebCore/khtml/dom/dom_string.cpp
Index: dom_string.cpp
===================================================================
RCS file: /cvs/root/WebCore/khtml/dom/dom_string.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- dom_string.cpp 4 Dec 2005 23:14:26 -0000 1.23
+++ dom_string.cpp 16 Dec 2005 22:26:12 -0000 1.24
@@ -27,88 +27,50 @@
namespace DOM {
-
DOMString::DOMString(const QChar *str, uint len)
{
- if (!str) {
- m_impl = 0;
+ if (!str)
return;
- }
if (len == 0)
m_impl = DOMStringImpl::empty();
else
m_impl = new DOMStringImpl(str, len);
- m_impl->ref();
}
DOMString::DOMString(const QString &str)
{
- if (str.isNull()) {
- m_impl = 0;
- return;
- }
+ if (str.isNull())
+ return;
if (str.isEmpty())
m_impl = DOMStringImpl::empty();
else
m_impl = new DOMStringImpl(str.unicode(), str.length());
- m_impl->ref();
}
DOMString::DOMString(const char *str)
{
- if (!str) {
- m_impl = 0;
- return;
- }
+ if (!str)
+ return;
int l = strlen(str);
if (l == 0)
m_impl = DOMStringImpl::empty();
else
m_impl = new DOMStringImpl(str, l);
- m_impl->ref();
-}
-
-DOMString::DOMString(DOMStringImpl *i)
-{
- m_impl = i;
- if(m_impl) m_impl->ref();
-}
-
-DOMString::DOMString(const DOMString &other)
-{
- m_impl = other.m_impl;
- if(m_impl) m_impl->ref();
-}
-
-DOMString &DOMString::operator =(const DOMString &other)
-{
- if ( m_impl != other.m_impl ) {
- if(m_impl) m_impl->deref();
- m_impl = other.m_impl;
- if(m_impl) m_impl->ref();
- }
- return *this;
}
DOMString &DOMString::operator += (const DOMString &str)
{
- if(str.m_impl)
- {
- if(!m_impl)
- {
+ if (str.m_impl) {
+ if (!m_impl) {
// ### FIXME!!!
m_impl = str.m_impl;
- m_impl->ref();
return *this;
}
- DOMStringImpl *i = m_impl->copy();
- m_impl->deref();
- m_impl = i;
- m_impl->ref();
- m_impl->append(str.m_impl);
+ m_impl = m_impl->copy();
+ m_impl->append(str.m_impl.get());
}
return *this;
}
@@ -126,13 +88,10 @@
void DOMString::insert(DOMString str, uint pos)
{
- if(!m_impl)
- {
- m_impl = str.m_impl->copy();
- m_impl->ref();
- }
+ if (!m_impl)
+ m_impl = str.m_impl->copy();
else
- m_impl->insert(str.m_impl, pos);
+ m_impl->insert(str.m_impl.get(), pos);
}
@@ -140,7 +99,8 @@
{
static const QChar nullChar = 0;
- if(!m_impl || i >= m_impl->l ) return nullChar;
+ if (!m_impl || i >= m_impl->l )
+ return nullChar;
return *(m_impl->s+i);
}
@@ -148,10 +108,11 @@
int DOMString::find(const QChar c, int start) const
{
unsigned int l = start;
- if(!m_impl || l >= m_impl->l ) return -1;
- while( l < m_impl->l )
- {
- if( *(m_impl->s+l) == c ) return l;
+ if (!m_impl || l >= m_impl->l )
+ return -1;
+ while(l < m_impl->l) {
+ if (*(m_impl->s+l) == c)
+ return l;
l++;
}
return -1;
@@ -159,18 +120,21 @@
uint DOMString::length() const
{
- if(!m_impl) return 0;
+ if (!m_impl)
+ return 0;
return m_impl->l;
}
void DOMString::truncate( unsigned int len )
{
- if(m_impl) m_impl->truncate(len);
+ if (m_impl)
+ m_impl->truncate(len);
}
void DOMString::remove(unsigned int pos, int len)
{
- if(m_impl) m_impl->remove(pos, len);
+ if (m_impl)
+ m_impl->remove(pos, len);
}
DOMString DOMString::substring(unsigned int pos, unsigned int len) const
@@ -182,25 +146,29 @@
DOMString DOMString::split(unsigned int pos)
{
- if(!m_impl) return DOMString();
- return m_impl->split(pos);
+ if (!m_impl)
+ return DOMString();
+ return m_impl->split(pos);
}
DOMString DOMString::lower() const
{
- if(!m_impl) return DOMString();
- return m_impl->lower();
+ if (!m_impl)
+ return DOMString();
+ return m_impl->lower();
}
DOMString DOMString::upper() const
{
- if(!m_impl) return DOMString();
- return m_impl->upper();
+ if (!m_impl)
+ return DOMString();
+ return m_impl->upper();
}
bool DOMString::percentage(int &_percentage) const
{
- if(!m_impl || !m_impl->l) return false;
+ if (!m_impl || !m_impl->l)
+ return false;
if ( *(m_impl->s+m_impl->l-1) != QChar('%'))
return false;
@@ -211,27 +179,31 @@
QChar *DOMString::unicode() const
{
- if(!m_impl) return 0;
+ if (!m_impl)
+ return 0;
return m_impl->s;
}
QString DOMString::qstring() const
{
- if(!m_impl) return QString::null;
+ if (!m_impl)
+ return QString::null;
return QString(m_impl->s, m_impl->l);
}
int DOMString::toInt() const
{
- if(!m_impl) return 0;
+ if (!m_impl)
+ return 0;
return m_impl->toInt();
}
DOMString DOMString::copy() const
{
- if(!m_impl) return DOMString();
+ if (!m_impl)
+ return DOMString();
return m_impl->copy();
}
@@ -247,8 +219,9 @@
if ( !( a && b ) ) return true;
int l = as.length();
while ( l-- ) {
- if ( *a != *b && a->lower() != b->lower() ) return true;
- a++,b++;
+ if ( *a != *b && a->lower() != b->lower() )
+ return true;
+ a++,b++;
}
return false;
}
@@ -274,12 +247,12 @@
}
khtml::Length* DOMString::toCoordsArray(int& len) const
-{
+{
return m_impl ? m_impl->toCoordsArray(len) : 0;
}
khtml::Length* DOMString::toLengthArray(int& len) const
-{
+{
return m_impl ? m_impl->toLengthArray(len) : 0;
}
@@ -299,10 +272,10 @@
unsigned int l = a.length();
- if( l != b.length() ) return false;
+ if ( l != b.length() ) return false;
- if(!memcmp(a.unicode(), b.unicode(), l*sizeof(QChar)))
- return true;
+ if (!memcmp(a.unicode(), b.unicode(), l*sizeof(QChar)))
+ return true;
return false;
}
@@ -310,16 +283,16 @@
{
unsigned int l = a.length();
- if( l != b.length() ) return false;
+ if ( l != b.length() ) return false;
- if(!memcmp(a.unicode(), b.unicode(), l*sizeof(QChar)))
- return true;
+ if (!memcmp(a.unicode(), b.unicode(), l*sizeof(QChar)))
+ return true;
return false;
}
bool operator==( const DOMString &a, const char *b )
{
- DOMStringImpl *aimpl = a.m_impl;
+ DOMStringImpl *aimpl = a.m_impl.get();
if (!b)
return !aimpl;
1.16 +4 -10 WebCore/khtml/dom/dom_string.h
Index: dom_string.h
===================================================================
RCS file: /cvs/root/WebCore/khtml/dom/dom_string.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- dom_string.h 29 Aug 2005 21:29:11 -0000 1.15
+++ dom_string.h 16 Dec 2005 22:26:12 -0000 1.16
@@ -52,18 +52,12 @@
/**
* default constructor. Gives an empty DOMString
*/
- DOMString() : m_impl(0) { }
+ DOMString() { }
DOMString(const QChar *str, uint len);
DOMString(const QString &);
DOMString(const char *str);
- DOMString(DOMStringImpl *i);
- ~DOMString() { if(m_impl) m_impl->deref(); }
-
-
- // assign and copy
- DOMString(const DOMString &str);
- DOMString &operator =(const DOMString &str);
+ DOMString(DOMStringImpl *i) : m_impl(i) { }
/**
* append str to this string
@@ -117,7 +111,7 @@
* @internal get a handle to the imlementation of the DOMString
* Use at own risk!!!
*/
- DOMStringImpl *impl() const { return m_impl; }
+ DOMStringImpl *impl() const { return m_impl.get(); }
#ifdef __OBJC__
DOMString(NSString *);
@@ -130,7 +124,7 @@
#endif
protected:
- DOMStringImpl *m_impl;
+ RefPtr<DOMStringImpl> m_impl;
};
DOMString operator + (const DOMString &a, const DOMString &b);
More information about the webkit-changes
mailing list