зеркало из https://github.com/mozilla/pjs.git
relanding dwitte's string work "Excessive inlining in string libs" with a minor change to fix a build bustage. bug 196506. r=dbaron, sr=alec
This commit is contained in:
Родитель
4cf65180b8
Коммит
9a3eacfc95
|
@ -452,3 +452,55 @@ nsEmbedCString::GrowCapacity(size_type aNewCapacity)
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Copies of Distance() function (and things that it depends on) from
|
||||
// ../src/nsReadableUtils.cpp. This is needed to make the non-inline
|
||||
// constructors of nsDependentSubstring work in embed builds. We only
|
||||
// define this class in the standalone version of the lib since the
|
||||
// non-standalone will be using the copy in the string lib.
|
||||
// See bug 196506
|
||||
|
||||
#ifdef STRING_STANDALONE
|
||||
|
||||
template <class CharT> class CalculateLength
|
||||
{
|
||||
public:
|
||||
typedef CharT value_type;
|
||||
|
||||
CalculateLength() : mDistance(0) { }
|
||||
size_t GetDistance() const { return mDistance; }
|
||||
|
||||
PRUint32 write( const CharT*, PRUint32 N )
|
||||
{ mDistance += N; return N; }
|
||||
private:
|
||||
size_t mDistance;
|
||||
};
|
||||
|
||||
template <class CharT>
|
||||
inline
|
||||
size_t
|
||||
Distance_Impl( const nsReadingIterator<CharT>& aStart,
|
||||
const nsReadingIterator<CharT>& aEnd )
|
||||
{
|
||||
CalculateLength<CharT> sink;
|
||||
nsReadingIterator<CharT> fromBegin(aStart);
|
||||
copy_string(fromBegin, aEnd, sink);
|
||||
return sink.GetDistance();
|
||||
}
|
||||
|
||||
NS_COM
|
||||
size_t Distance( const nsAString::const_iterator& aStart, const nsAString::const_iterator& aEnd )
|
||||
{
|
||||
return Distance_Impl(aStart, aEnd);
|
||||
}
|
||||
|
||||
NS_COM
|
||||
size_t Distance( const nsACString::const_iterator& aStart, const nsACString::const_iterator& aEnd )
|
||||
{
|
||||
return Distance_Impl(aStart, aEnd);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -102,4 +102,4 @@ include $(topsrcdir)/config/rules.mk
|
|||
export:: $(STRING_CSRCS) $(EMBED_STRING_CSRCS)
|
||||
$(INSTALL) $^ .
|
||||
|
||||
DEFINES += -DXPCOM_GLUE
|
||||
DEFINES += -DXPCOM_GLUE -DEMBEDSTRING_STANDALONE
|
||||
|
|
|
@ -61,22 +61,8 @@ class NS_COM nsDependentSubstring
|
|||
virtual char_type* GetWritableFragment( fragment_type&, nsFragmentRequest, PRUint32 ) { return 0; }
|
||||
|
||||
public:
|
||||
nsDependentSubstring( const abstract_string_type& aString, PRUint32 aStartPos, PRUint32 aLength )
|
||||
: mString(aString),
|
||||
mStartPos( NS_MIN(aStartPos, aString.Length()) ),
|
||||
mLength( NS_MIN(aLength, aString.Length()-mStartPos) )
|
||||
{
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
nsDependentSubstring( const const_iterator& aStart, const const_iterator& aEnd )
|
||||
: mString(aStart.string())
|
||||
{
|
||||
const_iterator zeroPoint;
|
||||
mString.BeginReading(zeroPoint);
|
||||
mStartPos = Distance(zeroPoint, aStart);
|
||||
mLength = Distance(aStart, aEnd);
|
||||
}
|
||||
nsDependentSubstring( const abstract_string_type& aString, PRUint32 aStartPos, PRUint32 aLength );
|
||||
nsDependentSubstring( const const_iterator& aStart, const const_iterator& aEnd );
|
||||
|
||||
// nsDependentSubstring( const self_type& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsDependentSubstring(); // auto-generated destructor OK
|
||||
|
@ -113,22 +99,8 @@ class NS_COM nsDependentCSubstring
|
|||
virtual char_type* GetWritableFragment( fragment_type&, nsFragmentRequest, PRUint32 ) { return 0; }
|
||||
|
||||
public:
|
||||
nsDependentCSubstring( const abstract_string_type& aString, PRUint32 aStartPos, PRUint32 aLength )
|
||||
: mString(aString),
|
||||
mStartPos( NS_MIN(aStartPos, aString.Length()) ),
|
||||
mLength( NS_MIN(aLength, aString.Length()-mStartPos) )
|
||||
{
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
nsDependentCSubstring( const const_iterator& aStart, const const_iterator& aEnd )
|
||||
: mString(aStart.string())
|
||||
{
|
||||
const_iterator zeroPoint;
|
||||
mString.BeginReading(zeroPoint);
|
||||
mStartPos = Distance(zeroPoint, aStart);
|
||||
mLength = Distance(aStart, aEnd);
|
||||
}
|
||||
nsDependentCSubstring( const abstract_string_type& aString, PRUint32 aStartPos, PRUint32 aLength );
|
||||
nsDependentCSubstring( const const_iterator& aStart, const const_iterator& aEnd );
|
||||
|
||||
// nsDependentCSubstring( const self_type& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsDependentCSubstring(); // auto-generated destructor OK
|
||||
|
@ -155,20 +127,10 @@ class NS_COM nsDependentSingleFragmentSubstring
|
|||
typedef nsASingleFragmentString abstract_single_fragment_type;
|
||||
|
||||
void
|
||||
Rebind( const char_type* aStartPtr, const char_type* aEndPtr )
|
||||
{
|
||||
NS_ASSERTION(aStartPtr && aEndPtr, "nsDependentSingleFragmentString must wrap a non-NULL buffer");
|
||||
mHandle.DataStart(aStartPtr);
|
||||
mHandle.DataEnd(aEndPtr);
|
||||
}
|
||||
Rebind( const char_type* aStartPtr, const char_type* aEndPtr );
|
||||
|
||||
void
|
||||
Rebind( const abstract_single_fragment_type& aString, const PRUint32 aStartPos, const PRUint32 aLength )
|
||||
{
|
||||
const_char_iterator iter;
|
||||
mHandle.DataStart(aString.BeginReading(iter) + NS_MIN(aStartPos, aString.Length()));
|
||||
mHandle.DataEnd( NS_MIN(mHandle.DataStart() + aLength, aString.EndReading(iter)) );
|
||||
}
|
||||
Rebind( const abstract_single_fragment_type& aString, const PRUint32 aStartPos, const PRUint32 aLength );
|
||||
|
||||
nsDependentSingleFragmentSubstring( const char_type* aStartPtr, const char_type* aEndPtr ) { Rebind(aStartPtr, aEndPtr); }
|
||||
nsDependentSingleFragmentSubstring( const abstract_single_fragment_type& aString, const PRUint32 aStartPos, const PRUint32 aLength ) { Rebind(aString, aStartPos, aLength); }
|
||||
|
@ -196,20 +158,10 @@ class NS_COM nsDependentSingleFragmentCSubstring
|
|||
typedef nsASingleFragmentCString abstract_single_fragment_type;
|
||||
|
||||
void
|
||||
Rebind( const char_type* aStartPtr, const char_type* aEndPtr )
|
||||
{
|
||||
NS_ASSERTION(aStartPtr && aEndPtr, "nsDependentSingleFragmentCString must wrap a non-NULL buffer");
|
||||
mHandle.DataStart(aStartPtr);
|
||||
mHandle.DataEnd(aEndPtr);
|
||||
}
|
||||
Rebind( const char_type* aStartPtr, const char_type* aEndPtr );
|
||||
|
||||
void
|
||||
Rebind( const abstract_single_fragment_type& aString, const PRUint32 aStartPos, const PRUint32 aLength )
|
||||
{
|
||||
const_char_iterator iter;
|
||||
mHandle.DataStart(aString.BeginReading(iter) + NS_MIN(aStartPos, aString.Length()));
|
||||
mHandle.DataEnd( NS_MIN(mHandle.DataStart() + aLength, aString.EndReading(iter)) );
|
||||
}
|
||||
Rebind( const abstract_single_fragment_type& aString, const PRUint32 aStartPos, const PRUint32 aLength );
|
||||
|
||||
nsDependentSingleFragmentCSubstring( const char_type* aStartPtr, const char_type* aEndPtr ) { Rebind(aStartPtr, aEndPtr); }
|
||||
nsDependentSingleFragmentCSubstring( const abstract_single_fragment_type& aString, const PRUint32 aStartPos, const PRUint32 aLength ) { Rebind(aString, aStartPos, aLength); }
|
||||
|
|
|
@ -1,123 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is Mozilla.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications. Portions created by Netscape Communications are
|
||||
* Copyright (C) 2001 by Netscape Communications. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Scott Collins <scc@mozilla.org> (original author)
|
||||
*/
|
||||
|
||||
#include "nsDependentSubstring.h"
|
||||
|
||||
PRUint32
|
||||
nsDependentSubstring::Length() const
|
||||
{
|
||||
return mLength;
|
||||
}
|
||||
|
||||
const nsDependentSubstring::char_type*
|
||||
nsDependentSubstring::GetReadableFragment( const_fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aPosition ) const
|
||||
{
|
||||
// Offset any request for a specific position (First, Last, At) by our
|
||||
// substrings startpos within the owning string
|
||||
|
||||
if ( aRequest == kFirstFragment )
|
||||
{
|
||||
aPosition = mStartPos;
|
||||
aRequest = kFragmentAt;
|
||||
}
|
||||
else if ( aRequest == kLastFragment )
|
||||
{
|
||||
aPosition = mStartPos + mLength;
|
||||
aRequest = kFragmentAt;
|
||||
}
|
||||
else if ( aRequest == kFragmentAt )
|
||||
aPosition += mStartPos;
|
||||
|
||||
// requests for |kNextFragment| or |kPrevFragment| are just relayed down into the string we're slicing
|
||||
|
||||
const char_type* position_ptr = mString.GetReadableFragment(aFragment, aRequest, aPosition);
|
||||
|
||||
// If |GetReadableFragment| returns |0|, then we are off the string, the contents of the
|
||||
// fragment are garbage.
|
||||
|
||||
// Therefore, only need to fix up the fragment boundaries when |position_ptr| is not null
|
||||
if ( position_ptr )
|
||||
{
|
||||
// if there's more physical data in the returned fragment than I logically have left...
|
||||
size_t logical_size_backward = aPosition - mStartPos;
|
||||
if ( size_t(position_ptr - aFragment.mStart) > logical_size_backward )
|
||||
aFragment.mStart = position_ptr - logical_size_backward;
|
||||
|
||||
size_t logical_size_forward = mLength - logical_size_backward;
|
||||
if ( size_t(aFragment.mEnd - position_ptr) > logical_size_forward )
|
||||
aFragment.mEnd = position_ptr + logical_size_forward;
|
||||
}
|
||||
|
||||
return position_ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
PRUint32
|
||||
nsDependentCSubstring::Length() const
|
||||
{
|
||||
return mLength;
|
||||
}
|
||||
|
||||
const nsDependentCSubstring::char_type*
|
||||
nsDependentCSubstring::GetReadableFragment( const_fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aPosition ) const
|
||||
{
|
||||
// Offset any request for a specific position (First, Last, At) by our
|
||||
// substrings startpos within the owning string
|
||||
|
||||
if ( aRequest == kFirstFragment )
|
||||
{
|
||||
aPosition = mStartPos;
|
||||
aRequest = kFragmentAt;
|
||||
}
|
||||
else if ( aRequest == kLastFragment )
|
||||
{
|
||||
aPosition = mStartPos + mLength;
|
||||
aRequest = kFragmentAt;
|
||||
}
|
||||
else if ( aRequest == kFragmentAt )
|
||||
aPosition += mStartPos;
|
||||
|
||||
// requests for |kNextFragment| or |kPrevFragment| are just relayed down into the string we're slicing
|
||||
|
||||
const char_type* position_ptr = mString.GetReadableFragment(aFragment, aRequest, aPosition);
|
||||
|
||||
// If |GetReadableFragment| returns |0|, then we are off the string, the contents of the
|
||||
// fragment are garbage.
|
||||
|
||||
// Therefore, only need to fix up the fragment boundaries when |position_ptr| is not null
|
||||
if ( position_ptr )
|
||||
{
|
||||
// if there's more physical data in the returned fragment than I logically have left...
|
||||
size_t logical_size_backward = aPosition - mStartPos;
|
||||
if ( size_t(position_ptr - aFragment.mStart) > logical_size_backward )
|
||||
aFragment.mStart = position_ptr - logical_size_backward;
|
||||
|
||||
size_t logical_size_forward = mLength - logical_size_backward;
|
||||
if ( size_t(aFragment.mEnd - position_ptr) > logical_size_forward )
|
||||
aFragment.mEnd = position_ptr + logical_size_forward;
|
||||
}
|
||||
|
||||
return position_ptr;
|
||||
}
|
|
@ -452,3 +452,55 @@ nsEmbedCString::GrowCapacity(size_type aNewCapacity)
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Copies of Distance() function (and things that it depends on) from
|
||||
// ../src/nsReadableUtils.cpp. This is needed to make the non-inline
|
||||
// constructors of nsDependentSubstring work in embed builds. We only
|
||||
// define this class in the standalone version of the lib since the
|
||||
// non-standalone will be using the copy in the string lib.
|
||||
// See bug 196506
|
||||
|
||||
#ifdef STRING_STANDALONE
|
||||
|
||||
template <class CharT> class CalculateLength
|
||||
{
|
||||
public:
|
||||
typedef CharT value_type;
|
||||
|
||||
CalculateLength() : mDistance(0) { }
|
||||
size_t GetDistance() const { return mDistance; }
|
||||
|
||||
PRUint32 write( const CharT*, PRUint32 N )
|
||||
{ mDistance += N; return N; }
|
||||
private:
|
||||
size_t mDistance;
|
||||
};
|
||||
|
||||
template <class CharT>
|
||||
inline
|
||||
size_t
|
||||
Distance_Impl( const nsReadingIterator<CharT>& aStart,
|
||||
const nsReadingIterator<CharT>& aEnd )
|
||||
{
|
||||
CalculateLength<CharT> sink;
|
||||
nsReadingIterator<CharT> fromBegin(aStart);
|
||||
copy_string(fromBegin, aEnd, sink);
|
||||
return sink.GetDistance();
|
||||
}
|
||||
|
||||
NS_COM
|
||||
size_t Distance( const nsAString::const_iterator& aStart, const nsAString::const_iterator& aEnd )
|
||||
{
|
||||
return Distance_Impl(aStart, aEnd);
|
||||
}
|
||||
|
||||
NS_COM
|
||||
size_t Distance( const nsACString::const_iterator& aStart, const nsACString::const_iterator& aEnd )
|
||||
{
|
||||
return Distance_Impl(aStart, aEnd);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -102,4 +102,4 @@ include $(topsrcdir)/config/rules.mk
|
|||
export:: $(STRING_CSRCS) $(EMBED_STRING_CSRCS)
|
||||
$(INSTALL) $^ .
|
||||
|
||||
DEFINES += -DXPCOM_GLUE
|
||||
DEFINES += -DXPCOM_GLUE -DEMBEDSTRING_STANDALONE
|
||||
|
|
|
@ -61,22 +61,8 @@ class NS_COM nsDependentSubstring
|
|||
virtual char_type* GetWritableFragment( fragment_type&, nsFragmentRequest, PRUint32 ) { return 0; }
|
||||
|
||||
public:
|
||||
nsDependentSubstring( const abstract_string_type& aString, PRUint32 aStartPos, PRUint32 aLength )
|
||||
: mString(aString),
|
||||
mStartPos( NS_MIN(aStartPos, aString.Length()) ),
|
||||
mLength( NS_MIN(aLength, aString.Length()-mStartPos) )
|
||||
{
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
nsDependentSubstring( const const_iterator& aStart, const const_iterator& aEnd )
|
||||
: mString(aStart.string())
|
||||
{
|
||||
const_iterator zeroPoint;
|
||||
mString.BeginReading(zeroPoint);
|
||||
mStartPos = Distance(zeroPoint, aStart);
|
||||
mLength = Distance(aStart, aEnd);
|
||||
}
|
||||
nsDependentSubstring( const abstract_string_type& aString, PRUint32 aStartPos, PRUint32 aLength );
|
||||
nsDependentSubstring( const const_iterator& aStart, const const_iterator& aEnd );
|
||||
|
||||
// nsDependentSubstring( const self_type& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsDependentSubstring(); // auto-generated destructor OK
|
||||
|
@ -113,22 +99,8 @@ class NS_COM nsDependentCSubstring
|
|||
virtual char_type* GetWritableFragment( fragment_type&, nsFragmentRequest, PRUint32 ) { return 0; }
|
||||
|
||||
public:
|
||||
nsDependentCSubstring( const abstract_string_type& aString, PRUint32 aStartPos, PRUint32 aLength )
|
||||
: mString(aString),
|
||||
mStartPos( NS_MIN(aStartPos, aString.Length()) ),
|
||||
mLength( NS_MIN(aLength, aString.Length()-mStartPos) )
|
||||
{
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
nsDependentCSubstring( const const_iterator& aStart, const const_iterator& aEnd )
|
||||
: mString(aStart.string())
|
||||
{
|
||||
const_iterator zeroPoint;
|
||||
mString.BeginReading(zeroPoint);
|
||||
mStartPos = Distance(zeroPoint, aStart);
|
||||
mLength = Distance(aStart, aEnd);
|
||||
}
|
||||
nsDependentCSubstring( const abstract_string_type& aString, PRUint32 aStartPos, PRUint32 aLength );
|
||||
nsDependentCSubstring( const const_iterator& aStart, const const_iterator& aEnd );
|
||||
|
||||
// nsDependentCSubstring( const self_type& ); // auto-generated copy-constructor should be OK
|
||||
// ~nsDependentCSubstring(); // auto-generated destructor OK
|
||||
|
@ -155,20 +127,10 @@ class NS_COM nsDependentSingleFragmentSubstring
|
|||
typedef nsASingleFragmentString abstract_single_fragment_type;
|
||||
|
||||
void
|
||||
Rebind( const char_type* aStartPtr, const char_type* aEndPtr )
|
||||
{
|
||||
NS_ASSERTION(aStartPtr && aEndPtr, "nsDependentSingleFragmentString must wrap a non-NULL buffer");
|
||||
mHandle.DataStart(aStartPtr);
|
||||
mHandle.DataEnd(aEndPtr);
|
||||
}
|
||||
Rebind( const char_type* aStartPtr, const char_type* aEndPtr );
|
||||
|
||||
void
|
||||
Rebind( const abstract_single_fragment_type& aString, const PRUint32 aStartPos, const PRUint32 aLength )
|
||||
{
|
||||
const_char_iterator iter;
|
||||
mHandle.DataStart(aString.BeginReading(iter) + NS_MIN(aStartPos, aString.Length()));
|
||||
mHandle.DataEnd( NS_MIN(mHandle.DataStart() + aLength, aString.EndReading(iter)) );
|
||||
}
|
||||
Rebind( const abstract_single_fragment_type& aString, const PRUint32 aStartPos, const PRUint32 aLength );
|
||||
|
||||
nsDependentSingleFragmentSubstring( const char_type* aStartPtr, const char_type* aEndPtr ) { Rebind(aStartPtr, aEndPtr); }
|
||||
nsDependentSingleFragmentSubstring( const abstract_single_fragment_type& aString, const PRUint32 aStartPos, const PRUint32 aLength ) { Rebind(aString, aStartPos, aLength); }
|
||||
|
@ -196,20 +158,10 @@ class NS_COM nsDependentSingleFragmentCSubstring
|
|||
typedef nsASingleFragmentCString abstract_single_fragment_type;
|
||||
|
||||
void
|
||||
Rebind( const char_type* aStartPtr, const char_type* aEndPtr )
|
||||
{
|
||||
NS_ASSERTION(aStartPtr && aEndPtr, "nsDependentSingleFragmentCString must wrap a non-NULL buffer");
|
||||
mHandle.DataStart(aStartPtr);
|
||||
mHandle.DataEnd(aEndPtr);
|
||||
}
|
||||
Rebind( const char_type* aStartPtr, const char_type* aEndPtr );
|
||||
|
||||
void
|
||||
Rebind( const abstract_single_fragment_type& aString, const PRUint32 aStartPos, const PRUint32 aLength )
|
||||
{
|
||||
const_char_iterator iter;
|
||||
mHandle.DataStart(aString.BeginReading(iter) + NS_MIN(aStartPos, aString.Length()));
|
||||
mHandle.DataEnd( NS_MIN(mHandle.DataStart() + aLength, aString.EndReading(iter)) );
|
||||
}
|
||||
Rebind( const abstract_single_fragment_type& aString, const PRUint32 aStartPos, const PRUint32 aLength );
|
||||
|
||||
nsDependentSingleFragmentCSubstring( const char_type* aStartPtr, const char_type* aEndPtr ) { Rebind(aStartPtr, aEndPtr); }
|
||||
nsDependentSingleFragmentCSubstring( const abstract_single_fragment_type& aString, const PRUint32 aStartPos, const PRUint32 aLength ) { Rebind(aString, aStartPos, aLength); }
|
||||
|
|
|
@ -23,6 +23,23 @@
|
|||
|
||||
#include "nsDependentSubstring.h"
|
||||
|
||||
nsDependentSubstring::nsDependentSubstring( const abstract_string_type& aString, PRUint32 aStartPos, PRUint32 aLength )
|
||||
: mString(aString),
|
||||
mStartPos( NS_MIN(aStartPos, aString.Length()) ),
|
||||
mLength( NS_MIN(aLength, aString.Length()-mStartPos) )
|
||||
{
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
nsDependentSubstring::nsDependentSubstring( const const_iterator& aStart, const const_iterator& aEnd )
|
||||
: mString(aStart.string())
|
||||
{
|
||||
const_iterator zeroPoint;
|
||||
mString.BeginReading(zeroPoint);
|
||||
mStartPos = Distance(zeroPoint, aStart);
|
||||
mLength = Distance(aStart, aEnd);
|
||||
}
|
||||
|
||||
PRUint32
|
||||
nsDependentSubstring::Length() const
|
||||
{
|
||||
|
@ -71,8 +88,22 @@ nsDependentSubstring::GetReadableFragment( const_fragment_type& aFragment, nsFra
|
|||
return position_ptr;
|
||||
}
|
||||
|
||||
nsDependentCSubstring::nsDependentCSubstring( const abstract_string_type& aString, PRUint32 aStartPos, PRUint32 aLength )
|
||||
: mString(aString),
|
||||
mStartPos( NS_MIN(aStartPos, aString.Length()) ),
|
||||
mLength( NS_MIN(aLength, aString.Length()-mStartPos) )
|
||||
{
|
||||
// nothing else to do here
|
||||
}
|
||||
|
||||
|
||||
nsDependentCSubstring::nsDependentCSubstring( const const_iterator& aStart, const const_iterator& aEnd )
|
||||
: mString(aStart.string())
|
||||
{
|
||||
const_iterator zeroPoint;
|
||||
mString.BeginReading(zeroPoint);
|
||||
mStartPos = Distance(zeroPoint, aStart);
|
||||
mLength = Distance(aStart, aEnd);
|
||||
}
|
||||
|
||||
PRUint32
|
||||
nsDependentCSubstring::Length() const
|
||||
|
@ -121,3 +152,35 @@ nsDependentCSubstring::GetReadableFragment( const_fragment_type& aFragment, nsFr
|
|||
|
||||
return position_ptr;
|
||||
}
|
||||
|
||||
void
|
||||
nsDependentSingleFragmentSubstring::Rebind( const char_type* aStartPtr, const char_type* aEndPtr )
|
||||
{
|
||||
NS_ASSERTION(aStartPtr && aEndPtr, "nsDependentSingleFragmentString must wrap a non-NULL buffer");
|
||||
mHandle.DataStart(aStartPtr);
|
||||
mHandle.DataEnd(aEndPtr);
|
||||
}
|
||||
|
||||
void
|
||||
nsDependentSingleFragmentSubstring::Rebind( const abstract_single_fragment_type& aString, const PRUint32 aStartPos, const PRUint32 aLength )
|
||||
{
|
||||
const_char_iterator iter;
|
||||
mHandle.DataStart(aString.BeginReading(iter) + NS_MIN(aStartPos, aString.Length()));
|
||||
mHandle.DataEnd( NS_MIN(mHandle.DataStart() + aLength, aString.EndReading(iter)) );
|
||||
}
|
||||
|
||||
void
|
||||
nsDependentSingleFragmentCSubstring::Rebind( const char_type* aStartPtr, const char_type* aEndPtr )
|
||||
{
|
||||
NS_ASSERTION(aStartPtr && aEndPtr, "nsDependentSingleFragmentCString must wrap a non-NULL buffer");
|
||||
mHandle.DataStart(aStartPtr);
|
||||
mHandle.DataEnd(aEndPtr);
|
||||
}
|
||||
|
||||
void
|
||||
nsDependentSingleFragmentCSubstring::Rebind( const abstract_single_fragment_type& aString, const PRUint32 aStartPos, const PRUint32 aLength )
|
||||
{
|
||||
const_char_iterator iter;
|
||||
mHandle.DataStart(aString.BeginReading(iter) + NS_MIN(aStartPos, aString.Length()));
|
||||
mHandle.DataEnd( NS_MIN(mHandle.DataStart() + aLength, aString.EndReading(iter)) );
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче