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

git-svn-id: svn://10.0.0.236/trunk@139723 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dougt%netscape.com
2003-03-18 23:48:44 +00:00
parent f1439dfbfc
commit 4f267db1dd
8 changed files with 250 additions and 116 deletions

View File

@@ -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