]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_utils.C
small cleanup, doxygen, formatting changes
[lyx.git] / src / mathed / math_utils.C
index a5fb789cce7f7202f07fd89f1902c8c081535208..14e43528feb8d05e88693d3e438fbaa99a44c3d8 100644 (file)
@@ -4,7 +4,7 @@
  *  Author:      Alejandro Aguilar Sierra <asierra@servidor.unam.mx> 
  *  Created:     August 1996
  *  
- *  Copyright: (c) 1996, 1997 Alejandro Aguilar Sierra
+ *  Copyright: 1996, 1997 Alejandro Aguilar Sierra
  *
  *  License: GNU GPL version 2 or later
  */
@@ -25,6 +25,8 @@ struct binary_op_pair {
        short isrel;
 };
 
+
+static
 binary_op_pair binary_op_table[] = {
       { LM_leq, LMB_RELATION }, { LM_geq, LMB_RELATION }, 
       { LM_equiv, LMB_RELATION }, { LM_models, LMB_RELATION }, 
@@ -64,32 +66,32 @@ binary_op_pair binary_op_table[] = {
 
 
 struct compara {
-       // used by sort
+       // used by sort and lower_bound
+       inline
        int operator()(binary_op_pair const & a,
                       binary_op_pair const & b) const {
                return a.id < b.id;
        }
-       // used by lower_bound
-       int operator()(binary_op_pair const & a, short int id) const {
-               return a.id < id;
-       }
 };
 
 
 int MathedLookupBOP(short id)
 {
-       static int bopCount = sizeof(binary_op_table) / sizeof(binary_op_pair);
+       static int const bopCount =
+               sizeof(binary_op_table) / sizeof(binary_op_pair);
        static bool issorted = false;
        
        if (!issorted) {
                sort(binary_op_table, binary_op_table + bopCount, compara());
                issorted = true;
        }
+
+       binary_op_pair search_elem = { id, 0 };
        
        binary_op_pair * res = lower_bound(binary_op_table,
                                           binary_op_table + bopCount,
-                                          id, compara());
-       if (res->id == id)
+                                          search_elem, compara());
+       if (res != binary_op_table + bopCount && res->id == id)
                return res->isrel;
        else
                return LMB_NONE;