From 816b7fdd912bf8d543b3c696dbc47aaa9b0dbee9 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Fri, 19 Feb 2010 08:11:09 +0000 Subject: [PATCH] Simplify featureAsString()... I don't understand why some people insist on those complicated, verbose STL code... git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33504 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/insets/InsetTabular.cpp | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 487d03b6bc..935516d5cb 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -174,18 +174,6 @@ TabularFeature tabularFeature[] = }; -class FeatureEqual : public unary_function { -public: - FeatureEqual(Tabular::Feature feature) - : feature_(feature) {} - bool operator()(TabularFeature const & tf) const { - return tf.action == feature_; - } -private: - Tabular::Feature feature_; -}; - - template string const write_attribute(string const & name, T const & t) { @@ -500,13 +488,13 @@ void l_getline(istream & is, string & str) } // namespace -string const featureAsString(Tabular::Feature feature) +string const featureAsString(Tabular::Feature action) { - TabularFeature * end = tabularFeature + - sizeof(tabularFeature) / sizeof(TabularFeature); - TabularFeature * it = find_if(tabularFeature, end, - FeatureEqual(feature)); - return (it == end) ? string() : it->feature; + for (size_t i = 0; i != Tabular::LAST_ACTION; ++i) { + if (tabularFeature[i].action == action) + return tabularFeature[i].feature; + } + return string(); }