landing string defragmentation patch for bug 231995, r/sr=dbaron,jst,dougt

git-svn-id: svn://10.0.0.236/trunk@152905 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
darin%meer.net
2004-02-19 02:44:03 +00:00
parent a63ea3848d
commit 55688e6410
223 changed files with 12792 additions and 16860 deletions

View File

@@ -1,139 +1,49 @@
/* -*- 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.
*
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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)
*/
*
* The Initial Developer of the Original Code is IBM Corporation.
* Portions created by IBM Corporation are Copyright (C) 2003
* IBM Corporation. All Rights Reserved.
*
* Contributor(s):
* Darin Fisher <darin@meer.net>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsPromiseFlatString.h"
// define nsPromiseFlatString
#include "string-template-def-unichar.h"
#include "nsTPromiseFlatString.cpp"
#include "string-template-undef.h"
nsPromiseFlatString::nsPromiseFlatString( const self_type& aOther )
: mFlattenedString(aOther.mFlattenedString)
{
if ( aOther.mPromisedString == &aOther.mFlattenedString )
mPromisedString = &mFlattenedString;
else
mPromisedString = aOther.mPromisedString;
}
nsPromiseFlatString::nsPromiseFlatString( const abstract_string_type& aString )
{
if ( aString.GetFlatBufferHandle() )
mPromisedString = NS_STATIC_CAST(const nsAFlatString*, &aString);
else
{
mFlattenedString = aString; // flatten |aString|
mPromisedString = &mFlattenedString;
}
}
const nsPromiseFlatString::buffer_handle_type*
nsPromiseFlatString::GetFlatBufferHandle() const
{
return mPromisedString->GetFlatBufferHandle();
}
const nsPromiseFlatString::buffer_handle_type*
nsPromiseFlatString::GetBufferHandle() const
{
return mPromisedString->GetBufferHandle();
}
const nsPromiseFlatString::shared_buffer_handle_type*
nsPromiseFlatString::GetSharedBufferHandle() const
{
return mPromisedString->GetSharedBufferHandle();
}
const nsPromiseFlatString::char_type*
nsPromiseFlatString::get() const
{
return mPromisedString->get();
}
PRUint32
nsPromiseFlatString::Length() const
{
return mPromisedString->Length();
}
const nsPromiseFlatString::char_type*
nsPromiseFlatString::GetReadableFragment( const_fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset ) const
{
return mPromisedString->GetReadableFragment(aFragment, aRequest, aOffset);
}
nsPromiseFlatCString::nsPromiseFlatCString( const self_type& aOther )
: mFlattenedString(aOther.mFlattenedString)
{
if ( aOther.mPromisedString == &aOther.mFlattenedString )
mPromisedString = &mFlattenedString;
else
mPromisedString = aOther.mPromisedString;
}
nsPromiseFlatCString::nsPromiseFlatCString( const abstract_string_type& aString )
{
if ( aString.GetFlatBufferHandle() )
mPromisedString = NS_STATIC_CAST(const nsAFlatCString*, &aString);
else
{
mFlattenedString = aString; // flatten |aString|
mPromisedString = &mFlattenedString;
}
}
const nsPromiseFlatCString::buffer_handle_type*
nsPromiseFlatCString::GetFlatBufferHandle() const
{
return mPromisedString->GetFlatBufferHandle();
}
const nsPromiseFlatCString::buffer_handle_type*
nsPromiseFlatCString::GetBufferHandle() const
{
return mPromisedString->GetBufferHandle();
}
const nsPromiseFlatCString::shared_buffer_handle_type*
nsPromiseFlatCString::GetSharedBufferHandle() const
{
return mPromisedString->GetSharedBufferHandle();
}
const nsPromiseFlatCString::char_type*
nsPromiseFlatCString::get() const
{
return mPromisedString->get();
}
PRUint32
nsPromiseFlatCString::Length() const
{
return mPromisedString->Length();
}
const nsPromiseFlatCString::char_type*
nsPromiseFlatCString::GetReadableFragment( const_fragment_type& aFragment, nsFragmentRequest aRequest, PRUint32 aOffset ) const
{
return mPromisedString->GetReadableFragment(aFragment, aRequest, aOffset);
}
// define nsPromiseFlatCString
#include "string-template-def-char.h"
#include "nsTPromiseFlatString.cpp"
#include "string-template-undef.h"