From 0453939fbe12fa9444307781041d3d62f0f522af Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 9 Aug 2001 15:56:38 +0000 Subject: [PATCH] remove unneeded code git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2470 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/math_hash.C | 71 +++++++++++----------------------------- src/mathed/math_parser.h | 4 --- 2 files changed, 20 insertions(+), 55 deletions(-) diff --git a/src/mathed/math_hash.C b/src/mathed/math_hash.C index d011174516..3987f3153e 100644 --- a/src/mathed/math_hash.C +++ b/src/mathed/math_hash.C @@ -1,14 +1,13 @@ #include -#include -#include "math_defs.h" #include "math_parser.h" -#include "support/lstrings.h" -#include +#include namespace { -latexkeys const wordlist[] = +// This lists needs to remain sorted all the time! + +latexkeys wordlist[] = { //{"displaystyle", LM_TK_STY, LM_ST_DISPLAY, LMB_NONE}, //{"oint", LM_TK_BIGSYM, LM_oint, LMB_NONE}, @@ -302,50 +301,22 @@ latexkeys const wordlist[] = }; -struct symbolindex { - unsigned int id; - short token; - - symbolindex(unsigned int i, short t) : id(i), token(t) - {} - - bool operator<(symbolindex const & s) const - { - return (id < s.id) || (id == s.id && token < s.token); - } -}; - +bool operator<(const latexkeys & a, const latexkeys & b) +{ + return string(a.name) < string(b.name); +} -// global maps -std::map LatexkeyById; -std::map LatexkeyByName; +// the "Initializer": Its default constructor is executed on loading and +// sorts the list. Not exactly needed as long as the list is kept sorted +// but who knows... -// helper structure to initialize the maps on startup: struct init { init() { - int const n = sizeof(wordlist)/sizeof(wordlist[0]); - for (latexkeys const * it = wordlist; it != wordlist + n; ++it) { - if (LatexkeyByName.find(it->name) != LatexkeyByName.end()) { - std::cerr << "math_hash.C: Bug: Duplicate entry: " - << it->name << std::endl; - } - LatexkeyByName[it->name] = it - wordlist; - if (it->id != 0 && - LatexkeyById.find(symbolindex(it->id, it->token)) != - LatexkeyById.end()) { - std::cerr << "math_hash.C: Bug: Duplicate entry: " - << it->name << " Id: " - << it->id << " token: " << it->token - << std::endl; - } - LatexkeyById[symbolindex(it->id, it->token)] = it - wordlist; - } + std::sort(wordlist, wordlist + sizeof(wordlist)/sizeof(wordlist[0])); } }; -// the "Initializer": Its default constructor is executed on loading and -// fills the maps static init dummy; } // namespace anon @@ -353,14 +324,12 @@ static init dummy; latexkeys const * in_word_set(string const & str) { - std::map::const_iterator pos = LatexkeyByName.find(str); - return pos == LatexkeyByName.end() ? 0 : &wordlist[pos->second]; -} - - -latexkeys const * lm_get_key_by_id(unsigned int id, short tc) -{ - std::map::const_iterator pos - = LatexkeyById.find(symbolindex(id, tc)); - return pos == LatexkeyById.end() ? 0 : &wordlist[pos->second]; +#ifdef WITH_WARNINGS +#warning Not nice yet... +#endif + latexkeys tmp; + tmp.name = str.c_str(); + int const n = sizeof(wordlist)/sizeof(wordlist[0]); + latexkeys const * pos = std::lower_bound(wordlist, wordlist + n, tmp); + return (string(pos->name) == str) ? pos : 0; } diff --git a/src/mathed/math_parser.h b/src/mathed/math_parser.h index 1e9144a93a..fa2e929d15 100644 --- a/src/mathed/math_parser.h +++ b/src/mathed/math_parser.h @@ -119,10 +119,6 @@ struct latexkeys { /// latexkeys const * in_word_set(string const & str); -/// -latexkeys const * lm_get_key_by_id(unsigned int id, short tc); - - MathMatrixInset * mathed_parse_normal(string const &); MathMatrixInset * mathed_parse_normal(std::istream &); MathMatrixInset * mathed_parse_normal(LyXLex &); -- 2.39.5