From cd015f9340320660b339b16e3a76071df3967fb0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 15 Mar 2017 17:14:40 +0100 Subject: [PATCH] - make the colormap comparison against NormalLight inline because this is by far the most frequent case and any cycle being saved here counts. --- src/r_data/colormaps.cpp | 1 - src/r_data/colormaps.h | 12 ++++++++++- src/serializer.cpp | 46 ---------------------------------------- 3 files changed, 11 insertions(+), 48 deletions(-) diff --git a/src/r_data/colormaps.cpp b/src/r_data/colormaps.cpp index d1dfc07e1..f87a70c3e 100644 --- a/src/r_data/colormaps.cpp +++ b/src/r_data/colormaps.cpp @@ -212,7 +212,6 @@ FDynamicColormap *GetSpecialLights (PalEntry color, PalEntry fade, int desaturat colormap->BuildLights (); } else colormap->Maps = NULL; - return colormap; } diff --git a/src/r_data/colormaps.h b/src/r_data/colormaps.h index 5b5802e92..cbb0bf1fa 100644 --- a/src/r_data/colormaps.h +++ b/src/r_data/colormaps.h @@ -1,6 +1,8 @@ #ifndef __RES_CMAP_H #define __RES_CMAP_H +#include "m_fixed.h" + struct FSWColormap; struct lightlist_t; @@ -149,8 +151,16 @@ extern bool NormalLightHasFixedLights; FDynamicColormap *GetSpecialLights (PalEntry lightcolor, PalEntry fadecolor, int desaturate); -inline FDynamicColormap *GetColorTable(const FColormap &cm) +__forceinline FDynamicColormap *GetColorTable(const FColormap &cm) { + auto p = &NormalLight; + if (cm.LightColor == p->Color && + cm.FadeColor == p->Fade && + cm.Desaturation == p->Desaturate) + { + return p; + } + return GetSpecialLights(cm.LightColor, cm.FadeColor, cm.Desaturation); } diff --git a/src/serializer.cpp b/src/serializer.cpp index fd9af832c..f514449ac 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -1715,52 +1715,6 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FName &value, FName *d // //========================================================================== -template<> FSerializer &Serialize(FSerializer &arc, const char *key, FDynamicColormap *&cm, FDynamicColormap **def) -{ - if (arc.isWriting()) - { - if (arc.w->inObject() && def != nullptr && cm->Color == (*def)->Color && cm->Fade == (*def)->Fade && cm->Desaturate == (*def)->Desaturate) - { - return arc; - } - - arc.WriteKey(key); - arc.w->StartArray(); - arc.w->Uint(cm->Color); - arc.w->Uint(cm->Fade); - arc.w->Uint(cm->Desaturate); - arc.w->EndArray(); - } - else - { - auto val = arc.r->FindKey(key); - if (val != nullptr) - { - if (val->IsArray()) - { - const rapidjson::Value &colorval = (*val)[0]; - const rapidjson::Value &fadeval = (*val)[1]; - const rapidjson::Value &desatval = (*val)[2]; - if (colorval.IsUint() && fadeval.IsUint() && desatval.IsUint()) - { - cm = GetSpecialLights(colorval.GetUint(), fadeval.GetUint(), desatval.GetUint()); - return arc; - } - } - assert(false && "not a colormap"); - Printf(TEXTCOLOR_RED "object does not represent a colormap for '%s'\n", key); - cm = &NormalLight; - } - } - return arc; -} - -//========================================================================== -// -// -// -//========================================================================== - FSerializer &Serialize(FSerializer &arc, const char *key, FSoundID &sid, FSoundID *def) { if (arc.isWriting())