From 3ca4c03f1d086161533ab6e19413d7fdb4458247 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Mon, 3 Oct 2016 17:21:52 -0400 Subject: [PATCH] Bug 1306616 - part 2 - remove nsWritingIterator::write; r=erahm Iterators shouldn't have methods like write(); if you need to write to an iterator, that logic should be handled by something outside of the iterator...which also explains why we have a specialization of nsCharTraits>. The HTML parser wants this for its own reasons, so we have to make sure it continues to work. --- xpcom/string/nsStringIterator.h | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/xpcom/string/nsStringIterator.h b/xpcom/string/nsStringIterator.h index a979349b1e6a..e309a21e9090 100644 --- a/xpcom/string/nsStringIterator.h +++ b/xpcom/string/nsStringIterator.h @@ -205,15 +205,6 @@ public: return *this; } - void write(const value_type* aS, uint32_t aN) - { - NS_ASSERTION(mEnd - mPosition > 0, - "You can't |write| into an |nsWritingIterator| with no space!"); - - nsCharTraits::move(mPosition, aS, aN); - advance(difference_type(aN)); - } - // We return an unsigned type here (with corresponding assert) rather than // the more usual difference_type because we want to make this class go // away in favor of mozilla::RangedPtr. Since RangedPtr has the same @@ -226,6 +217,17 @@ public: } }; +template +struct nsCharSinkTraits> +{ + static void + write(nsWritingIterator& aIter, const CharT* aStr, uint32_t aN) + { + nsCharTraits::move(aIter.get(), aStr, aN); + aIter.advance(aN); + } +}; + template inline bool operator==(const nsReadingIterator& aLhs,