diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index 3cb912ee123bd09531efe99af6b9e08e70252448..c8f86bb5afbb800eac3c8182f59f5f068c4f302b 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -1976,7 +1976,7 @@ void LLTextEditor::doDelete()
 	{	
 		S32 i;
 		S32 chars_to_remove = 1;
-		LLWString text = getWText();
+		const LLWString& text = getWText();
 		if( (text[ mCursorPos ] == ' ') && (mCursorPos + SPACES_PER_TAB < getLength()) )
 		{
 			// Try to remove a full tab's worth of spaces
@@ -2580,7 +2580,7 @@ void LLTextEditor::updateLinkSegments()
 {
 	if (!mParseHTML) return;
 
-	LLWString wtext = getWText();
+	const LLWString& wtext = getWText();
 
 	// update any segments that contain a link
 	for (const auto& mSegment : mSegments)
@@ -2900,7 +2900,7 @@ BOOL LLTextEditor::getPreeditLocation(S32 query_offset, LLCoordGL *coord, LLRect
 		current_line++;
 	}
 
-    const LLWString textString(getWText());
+    const LLWString& textString = getWText();
 	const llwchar * const text = textString.c_str();
 	const S32 line_height = mFont->getLineHeight();
 
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index 6b75cb17ac215b9343401f74f198b51f08e3f144..ceb4f0832770b199cf2a2bf6ecc86ffc7367bf8e 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -378,7 +378,7 @@ void LLView::removeChild(LLView* child)
 		llassert(!child->mInDraw);
 		mChildList.remove( child );
 
-		for(auto it=mChildHashMap.begin(); it != mChildHashMap.end(); ++it)
+		for(auto it=mChildHashMap.begin(), end = mChildHashMap.end(); it != end; ++it)
 		{
 			if(it->second == child)
 			{
diff --git a/indra/newview/llviewertexteditor.cpp b/indra/newview/llviewertexteditor.cpp
index df042bedd32420955f6ae75af1081d5e75019c50..3e7f7a3ab0eaa07275276f1f71a607b23e047593 100644
--- a/indra/newview/llviewertexteditor.cpp
+++ b/indra/newview/llviewertexteditor.cpp
@@ -1043,7 +1043,7 @@ void LLViewerTextEditor::onValueChange(S32 start, S32 end)
 
 void LLViewerTextEditor::findEmbeddedItemSegments(S32 start, S32 end)
 {
-	LLWString text = getWText();
+	const LLWString& text = getWText();
 
 	// Start with i just after the first embedded item
 	for(S32 idx = start; idx < end; idx++ )