From f2974ff46b371d7c0ba9534322d875881c674ad5 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Sun, 5 Jul 2020 12:57:14 -0400
Subject: [PATCH] Smol opt to draw

---
 indra/newview/lldrawpool.cpp          | 10 ++++++----
 indra/newview/lldrawpoolbump.cpp      | 10 ++++++----
 indra/newview/lldrawpoolmaterials.cpp | 10 ++++++----
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/indra/newview/lldrawpool.cpp b/indra/newview/lldrawpool.cpp
index f1767a641a2..35ea3404fa7 100644
--- a/indra/newview/lldrawpool.cpp
+++ b/indra/newview/lldrawpool.cpp
@@ -471,13 +471,15 @@ void LLRenderPass::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL ba
 
 	if (texture)
 	{
-		if (batch_textures && params.mTextureList.size() > 1)
+		const U32 tex_list_size = params.mTextureList.size();
+		if (batch_textures && tex_list_size > 1)
 		{
-			for (U32 i = 0; i < params.mTextureList.size(); ++i)
+			for (U32 i = 0; i < tex_list_size; ++i)
 			{
-				if (params.mTextureList[i].notNull())
+				LLViewerTexture* texture = params.mTextureList[i];
+				if (texture)
 				{
-					gGL.getTexUnit(i)->bind(params.mTextureList[i], TRUE);
+					gGL.getTexUnit(i)->bind(texture, TRUE);
 				}
 			}
 		}
diff --git a/indra/newview/lldrawpoolbump.cpp b/indra/newview/lldrawpoolbump.cpp
index f42fc69e13c..989127fb6fa 100644
--- a/indra/newview/lldrawpoolbump.cpp
+++ b/indra/newview/lldrawpoolbump.cpp
@@ -1504,13 +1504,15 @@ void LLDrawPoolBump::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture, BOOL
 
 	bool tex_setup = false;
 
-	if (batch_textures && params.mTextureList.size() > 1)
+	const U32 tex_list_size = params.mTextureList.size();
+	if (batch_textures && tex_list_size > 1)
 	{
-		for (U32 i = 0; i < params.mTextureList.size(); ++i)
+		for (U32 i = 0; i < tex_list_size; ++i)
 		{
-			if (params.mTextureList[i].notNull())
+			LLViewerTexture* texturep = params.mTextureList[i];
+			if (texturep)
 			{
-				gGL.getTexUnit(i)->bind(params.mTextureList[i], TRUE);
+				gGL.getTexUnit(i)->bind(texturep, TRUE);
 			}
 		}
 	}
diff --git a/indra/newview/lldrawpoolmaterials.cpp b/indra/newview/lldrawpoolmaterials.cpp
index 05b0c1f1a93..6d5339f917c 100644
--- a/indra/newview/lldrawpoolmaterials.cpp
+++ b/indra/newview/lldrawpoolmaterials.cpp
@@ -177,13 +177,15 @@ void LLDrawPoolMaterials::pushBatch(LLDrawInfo& params, U32 mask, BOOL texture,
 	
 	bool tex_setup = false;
 	
-	if (batch_textures && params.mTextureList.size() > 1)
+	const U32 tex_list_size = params.mTextureList.size();
+	if (batch_textures && tex_list_size > 1)
 	{
-		for (U32 i = 0; i < params.mTextureList.size(); ++i)
+		for (U32 i = 0; i < tex_list_size; ++i)
 		{
-			if (params.mTextureList[i].notNull())
+			LLViewerTexture* texturep = params.mTextureList[i];
+			if (texturep)
 			{
-				gGL.getTexUnit(i)->bind(params.mTextureList[i], TRUE);
+				gGL.getTexUnit(i)->bind(texturep, TRUE);
 			}
 		}
 	}
-- 
GitLab