]> git.tdb.fi Git - libs/gl.git/blobdiff - source/render/programdata.cpp
Use the new _member utility functions to search and sort things
[libs/gl.git] / source / render / programdata.cpp
index 8adde8a26f5b71705ea92929d0fc19cee5403907..272489bb585f0d9536dd94653b0b8fb039b42fea 100644 (file)
@@ -1,3 +1,4 @@
+#include <msp/core/algorithm.h>
 #include <msp/core/maputils.h>
 #include <msp/debug/demangle.h>
 #include <msp/gl/extensions/arb_direct_state_access.h>
@@ -173,7 +174,7 @@ void ProgramData::add_uniform(Tag tag, Uniform *uni)
                throw too_many_uniforms(tag.str());
        }
 
-       vector<TaggedUniform>::iterator j = lower_bound(uniforms.begin(), uniforms.end(), tag, uniform_tag_compare);
+       vector<TaggedUniform>::iterator j = lower_bound_member(uniforms, tag, &TaggedUniform::tag);
 
        TaggedUniform nu;
        nu.tag = tag;
@@ -456,7 +457,7 @@ void ProgramData::uniform_matrix4_array(Tag tag, unsigned n, const float *v)
 
 void ProgramData::remove_uniform(Tag tag)
 {
-       vector<TaggedUniform>::const_iterator i = lower_bound(uniforms.begin(), uniforms.end(), tag, uniform_tag_compare);
+       vector<TaggedUniform>::const_iterator i = lower_bound_member(uniforms, tag, &TaggedUniform::tag);
        if(i==uniforms.end() || i->tag!=tag)
                return;
 
@@ -489,14 +490,9 @@ const Uniform *ProgramData::find_uniform(Tag tag) const
        return (i>=0 ? uniforms[i].value : 0);
 }
 
-bool ProgramData::uniform_tag_compare(const TaggedUniform &tu, Tag tag)
-{
-       return tu.tag<tag;
-}
-
 int ProgramData::find_uniform_index(Tag tag) const
 {
-       vector<TaggedUniform>::const_iterator i = lower_bound(uniforms.begin(), uniforms.end(), tag, uniform_tag_compare);
+       vector<TaggedUniform>::const_iterator i = lower_bound_member(uniforms, tag, &TaggedUniform::tag);
        return ((i!=uniforms.end() && i->tag==tag) ? i-uniforms.begin() : -1);
 }