]> git.lyx.org Git - lyx.git/commitdiff
Use empty() to check empty and non-empty'ness not size()
authorLars Gullik Bjønnes <larsbj@gullik.org>
Sun, 21 Oct 2012 19:14:16 +0000 (21:14 +0200)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Fri, 26 Oct 2012 23:25:38 +0000 (01:25 +0200)
Also add FormatList::empty().

29 files changed:
src/BiblioInfo.cpp
src/Cursor.cpp
src/Format.h
src/KeySequence.cpp
src/Paragraph.cpp
src/client/client.cpp
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/GuiToolbar.cpp
src/frontends/qt4/Menus.cpp
src/graphics/GraphicsLoader.cpp
src/lyxfind.cpp
src/mathed/CommandInset.cpp
src/mathed/InsetMathBox.cpp
src/mathed/InsetMathExInt.cpp
src/mathed/InsetMathGrid.cpp
src/mathed/InsetMathHull.cpp
src/mathed/InsetMathScript.cpp
src/mathed/InsetMathXArrow.cpp
src/mathed/InsetMathXYArrow.cpp
src/mathed/MathAutoCorrect.cpp
src/mathed/MathData.cpp
src/mathed/MathExtern.cpp
src/mathed/MathMacro.cpp
src/mathed/MathMacroTemplate.cpp
src/mathed/MathParser.cpp
src/rowpainter.cpp
src/support/docstring.cpp
src/support/weighted_btree.h
src/tex2lyx/text.cpp

index bc46e17448d9aa7f0d8a048deb3910c521ad14a3..93094f8bfa0e704e10b584fcfb1dd69d3b0c9af4 100644 (file)
@@ -66,7 +66,7 @@ docstring familyName(docstring const & name)
        vector<docstring>::const_iterator it = pieces.begin();
        vector<docstring>::const_iterator en = pieces.end();
        for (; it != en; ++it) {
-               if ((*it).size() == 0)
+               if ((*it).empty())
                        continue;
                char_type const c = (*it)[0];
                if (isLower(c))
@@ -99,7 +99,7 @@ docstring convertLaTeXCommands(docstring const & str)
        bool scanning_cmd = false;
        bool scanning_math = false;
        bool escaped = false; // used to catch \$, etc.
-       while (val.size()) {
+       while (!val.empty()) {
                char_type const ch = val[0];
 
                // if we're scanning math, we output everything until we
@@ -323,7 +323,7 @@ namespace {
                fmt = fmt.substr(2);
                // we'll remove characters from the front of fmt as we
                // deal with them
-               while (fmt.size()) {
+               while (!fmt.empty()) {
                        if (fmt[0] == ']' && fmt.size() > 1 && fmt[1] == ']') {
                                // that's the end
                                fmt = fmt.substr(2);
@@ -415,7 +415,7 @@ docstring BibTeXInfo::expandFormat(string const & format,
        string fmt = format;
        // we'll remove characters from the front of fmt as we
        // deal with them
-       while (fmt.size()) {
+       while (!fmt.empty()) {
                if (counter++ > max_passes) {
                        LYXERR0("Recursion limit reached while parsing `"
                                << format << "'.");
index b0f7b7074ea5451d7a077f7e63aada6c010d6f6a..e38ca5ec1319db52428917da794d0c2b56daafdf 100644 (file)
@@ -588,7 +588,7 @@ void Cursor::checkNewWordPosition()
                        clearNewWordPosition();
                else {
                        FontSpan nw = locateWord(WHOLE_WORD);
-                       if (nw.size()) {
+                       if (!nw.empty()) {
                                FontSpan ow = new_word_.locateWord(WHOLE_WORD);
                                if (nw.intersect(ow).empty())
                                        clearNewWordPosition();
@@ -1637,7 +1637,7 @@ bool Cursor::macroModeClose()
                // we have to resolve the macro here manually and check its arity
                // to put the selection behind it if arity > 0.
                MacroData const * data = buffer()->getMacro(atomAsMacro->name());
-               if (selection.size() > 0 && data && data->numargs() - data->optionals() > 0) {
+               if (!selection.empty() && data && data->numargs() - data->optionals() > 0) {
                        macroArg = true;
                        atomAsMacro->setDisplayMode(MathMacro::DISPLAY_INTERACTIVE_INIT, 1);
                } else
index 9d91ae1442f7edaa380c30461d4d6b3c885196e1..b96120bc71cb6756a48338f642f06133be21c77d 100644 (file)
@@ -201,6 +201,8 @@ public:
        ///
        const_iterator end() const { return formatlist.end(); }
        ///
+       bool empty() const { return formatlist.empty(); }
+       ///
        FormatList::size_type size() const { return formatlist.size(); }
 private:
        ///
index a0f2f5bda2c3a970535a75600a7d702867852b4b..3bee9caadbd47ffb28c701b43b4adbff0a3b069b 100644 (file)
@@ -125,8 +125,7 @@ size_t KeySequence::parse(string const & s)
                }
        }
 
-       // empty sequence?
-       if (sequence.size() == 0)
+       if (sequence.empty())
                return 0;
 
        // everything is fine
index e80ddc1de3070113d72a892d5c9cb0f967e91d2f..5a6804785094daa4a51b3ed1776763c1d279918e 100644 (file)
@@ -3733,7 +3733,7 @@ SpellChecker::Result Paragraph::spellCheck(pos_type & from, pos_type & to,
 
        wl = WordLangTuple(word, lang);
 
-       if (!word.size())
+       if (word.empty())
                return result;
 
        if (needsSpellCheck() || check_learned) {
@@ -3830,7 +3830,7 @@ void Paragraph::Private::markMisspelledWords(
 void Paragraph::spellCheck() const
 {
        SpellChecker * speller = theSpellChecker();
-       if (!speller || !size() ||!needsSpellCheck())
+       if (!speller || empty() ||!needsSpellCheck())
                return;
        pos_type start;
        pos_type endpos;
index 105c1e9c0174e983f4dadd8ad2d12fdaaaba7217..19e38fae5174b8df8d088c594915968473aecf22 100644 (file)
@@ -462,7 +462,7 @@ docstring clientName =
 
 int n(vector<docstring> const & arg)
 {
-       if (arg.size() < 1) {
+       if (arg.empty()) {
                cerr << "lyxclient: The option -n requires 1 argument."
                     << endl;
                return -1;
@@ -477,7 +477,7 @@ docstring singleCommand;
 
 int c(vector<docstring> const & arg)
 {
-       if (arg.size() < 1) {
+       if (arg.empty()) {
                cerr << "lyxclient: The option -c requires 1 argument."
                     << endl;
                return -1;
@@ -507,7 +507,7 @@ docstring serverAddress;
 
 int a(vector<docstring> const & arg)
 {
-       if (arg.size() < 1) {
+       if (arg.empty()) {
                cerr << "lyxclient: The option -a requires 1 argument."
                     << endl;
                return -1;
@@ -522,7 +522,7 @@ int a(vector<docstring> const & arg)
 
 int t(vector<docstring> const & arg)
 {
-       if (arg.size() < 1) {
+       if (arg.empty()) {
                cerr << "lyxclient: The option -t requires 1 argument."
                     << endl;
                return -1;
@@ -537,7 +537,7 @@ string serverPid; // Init to empty string
 
 int p(vector<docstring> const & arg)
 {
-       if (arg.size() < 1) {
+       if (arg.empty()) {
                cerr << "lyxclient: The option -p requires 1 argument."
                     << endl;
                return -1;
index a65af05d76703ff4cb08ee2d8b8d2418459303c9..902d2dd9cd460a557196c0c437e456caf1f4bcb8 100644 (file)
@@ -1678,7 +1678,7 @@ void PrefConverters::changeConverter()
 
 void PrefConverters::updateButtons()
 {
-       if (form_->formats().size() == 0)
+       if (form_->formats().empty())
                return;
        Format const & from = form_->formats().get(converterFromCO->currentIndex());
        Format const & to = form_->formats().get(converterToCO->currentIndex());
@@ -1975,7 +1975,7 @@ void PrefFileformats::updateView()
 
 void PrefFileformats::on_formatsCB_currentIndexChanged(int i)
 {
-       if (form_->formats().size() == 0)
+       if (form_->formats().empty())
                return;
        int const nr = formatsCB->itemData(i).toInt();
        Format const f = form_->formats().get(nr);
index ec80a0b4300dc7c1912d829c86ad341df19cc533..a6f4505ce0418c5dd4da613150ff89bc5f833ece 100644 (file)
@@ -99,7 +99,7 @@ Action * GuiToolbar::addItem(ToolbarItem const & item)
        // Get the keys bound to this action, but keep only the
        // first one later
        KeyMap::Bindings bindings = theTopLevelKeymap().findBindings(item.func_);
-       if (bindings.size())
+       if (!bindings.empty())
                text += " [" + toqstr(bindings.begin()->print(KeySequence::ForGui)) + "]";
 
        Action * act = new Action(&owner_, getIcon(item.func_, false),
index 674afaf09a56f973d10b2f14a8df18fd295ae30a..279ccaea3c7dbf50638c053e42ae683cdcc75247 100644 (file)
@@ -241,7 +241,7 @@ public:
                // Get the keys bound to this action, but keep only the
                // first one later
                KeyMap::Bindings bindings = theTopLevelKeymap().findBindings(func_);
-               if (bindings.size())
+               if (!bindings.empty())
                        return toqstr(bindings.begin()->print(KeySequence::ForGui));
 
                LYXERR(Debug::KBMAP, "No binding for "
@@ -1301,7 +1301,7 @@ void MenuDefinition::expandToc(Buffer const * buf)
        if (cit == end)
                LYXERR(Debug::GUI, "No table of contents.");
        else {
-               if (cit->second.size() > 0 )
+               if (!cit->second.empty())
                        expandToc2(cit->second, 0, cit->second.size(), 0);
                else
                        add(MenuItem(MenuItem::Info, qt_("<Empty Table of Contents>")));
@@ -1574,7 +1574,7 @@ static QString label(MenuItem const & mi)
 void Menu::Impl::populate(QMenu & qMenu, MenuDefinition const & menu)
 {
        LYXERR(Debug::GUI, "populating menu " << menu.name());
-       if (menu.size() == 0) {
+       if (menu.empty()) {
                LYXERR(Debug::GUI, "\tERROR: empty menu " << menu.name());
                return;
        }
@@ -1759,7 +1759,7 @@ void Menus::Impl::macxMenuBarInit(GuiView * view, QMenuBar * qmb)
                {LFUN_LYX_QUIT, "", "Quit LyX", QAction::QuitRole}
        };
        const size_t num_entries = sizeof(entries) / sizeof(entries[0]);
-       const bool first_call = mac_special_menu_.size() == 0;
+       const bool first_call = mac_special_menu_.empty();
 
        // the special menu for Menus. Fill it up only once.
        if (first_call) {
@@ -2050,7 +2050,7 @@ void Menus::fillMenuBar(QMenuBar * qmb, GuiView * view, bool initial)
 
        LYXERR(Debug::GUI, "populating menu bar" << d->menubar_.name());
 
-       if (d->menubar_.size() == 0) {
+       if (d->menubar_.empty()) {
                LYXERR(Debug::GUI, "\tERROR: empty menu bar"
                        << d->menubar_.name());
                return;
@@ -2115,7 +2115,7 @@ void Menus::updateMenu(Menu * qmenu)
                MenuDefinition cat_menu = d->getMenu(toqstr(menu_name));
                //FIXME: 50 is a wild guess. We should take into account here
                //the expansion of menu items, disabled optional items etc.
-               bool const in_sub_menu = fromLyxMenu.size() > 0
+               bool const in_sub_menu = !fromLyxMenu.empty()
                        && fromLyxMenu.size() + cat_menu.size() > 50 ;
                if (in_sub_menu)
                        fromLyxMenu.catSub(menu_name);
index 5ed19c60eafec6825ef28a4b943f16439a46aa27..9f873baf3db09e56c4fccd14b28e2c06b264d015 100644 (file)
@@ -89,7 +89,7 @@ void LoaderQueue::loadNext()
        LYXERR(Debug::GRAPHICS, "LoaderQueue: "
                << cache_queue_.size() << " items in the queue");
        int counter = s_numimages_;
-       while (cache_queue_.size() && counter--) {
+       while (!cache_queue_.empty() && counter--) {
                Cache::ItemPtr ptr = cache_queue_.front();
                cache_set_.erase(ptr);
                cache_queue_.pop_front();
index 33dbd8a9d49c369db205aca549f85021db5367e8..74b045c4bba0cb2729916a640d5a1d7b2857da63 100644 (file)
@@ -968,10 +968,10 @@ string MatchStringAdv::normalize(docstring const & s, bool hack_braces) const
        else
                t = lyx::to_utf8(s);
        // Remove \n at begin
-       while (t.size() > 0 && t[0] == '\n')
+       while (!t.empty() && t[0] == '\n')
                t = t.substr(1);
        // Remove \n at end
-       while (t.size() > 0 && t[t.size() - 1] == '\n')
+       while (!t.empty() && t[t.size() - 1] == '\n')
                t = t.substr(0, t.size() - 1);
        size_t pos;
        // Replace all other \n with spaces
index e09604e241c9f2973f1cde97d07172c05a9d343d..0cf041c23ea7e59b2ec9fc62cf30690fca02cda5 100644 (file)
@@ -67,7 +67,7 @@ void CommandInset::write(WriteStream & os) const
        ModeSpecifier specifier(os, currentMode(), lockedMode(), asciiOnly());
        MathEnsurer ensurer(os, needs_math_mode_);
        os << '\\' << name_;
-       if (cell(1).size())
+       if (!cell(1).empty())
                os << '[' << cell(1) << ']';
        os << '{' << cell(0) << '}';
 }
index 60983bca804807efa2b9948913a37fdd14407912..8b3cb2b427b1c1938cf980bae60959072eebe8a9 100644 (file)
@@ -282,9 +282,9 @@ void InsetMathMakebox::write(WriteStream & os) const
 {
        ModeSpecifier specifier(os, TEXT_MODE);
        os << (framebox_ ? "\\framebox" : "\\makebox");
-       if (cell(0).size() || !os.latex()) {
+       if (!cell(0).empty() || !os.latex()) {
                os << '[' << cell(0) << ']';
-               if (cell(1).size() || !os.latex())
+               if (!cell(1).empty() || !os.latex())
                        os << '[' << cell(1) << ']';
        }
        os << '{' << cell(2) << '}';
index ac5409f469aca3e432a9173967890fe357f6d71e..64f49cd996778bbd80637c8ec9b7533622c12a36 100644 (file)
@@ -76,7 +76,7 @@ void InsetMathExInt::draw(PainterInfo &, int, int) const
 void InsetMathExInt::maple(MapleStream & os) const
 {
        os << symbol_ << '(';
-       if (cell(0).size())
+       if (!cell(0).empty())
                os << cell(0);
        else
                os << '1';
@@ -94,7 +94,7 @@ void InsetMathExInt::maxima(MaximaStream & os) const
        else
                os << symbol_ << '(';
 
-       if (cell(0).size())
+       if (!cell(0).empty())
                os << cell(0) << ',';
        else
                os << '1' << ',';
@@ -113,7 +113,7 @@ void InsetMathExInt::mathematica(MathematicaStream & os) const
        else
                os << symbol_ << '[';
 
-       if (cell(0).size())
+       if (!cell(0).empty())
                os << cell(0) << ',';
        else
                os << '1' << ',';
index ac8cd491acb8d50dafc3e132722550a1810fb381..e74d549c48506c91113e462d0345d2b518847664 100644 (file)
@@ -674,7 +674,7 @@ docstring InsetMathGrid::eolString(row_type row, bool fragile,
        // make sure an upcoming '[' does not break anything
        if (row + 1 < nrows()) {
                MathData const & c = cell(index(row + 1, 0));
-               if (c.size() && c.front()->getChar() == '[')
+               if (!c.empty() && c.front()->getChar() == '[')
                        //eol += "[0pt]";
                        eol += "{}";
        }
@@ -905,7 +905,7 @@ bool InsetMathGrid::idxDelete(idx_type & idx)
 
        // try to delete entire sequence of ncols() empty cells if possible
        for (idx_type i = idx; i < idx + ncols(); ++i)
-               if (cell(i).size())
+               if (!cell(i).empty())
                        return false;
 
        // move cells if necessary
index 1f135f54c2e6eafc7fe50160a35faec138901b83..6598bd913dcfaa27180870d765e4b3716c6968da 100644 (file)
@@ -1039,7 +1039,7 @@ void InsetMathHull::splitTo3Cols()
        InsetMathGrid::addCol(2);
        for (row_type row = 0; row < nrows(); ++row) {
                idx_type const i = 3 * row + 1;
-               if (cell(i).size()) {
+               if (!cell(i).empty()) {
                        cell(i + 1) = MathData(buffer_, cell(i).begin() + 1, cell(i).end());
                        cell(i).erase(1, cell(i).size());
                }
@@ -1309,7 +1309,7 @@ void InsetMathHull::doExtern(Cursor & cur, FuncRequest & func)
                MathData ar;
                if (cur.inMathed() && cur.selection()) {
                        asArray(grabAndEraseSelection(cur), ar);
-               } else if (pos == cur.cell().size()) {
+               } else if (!pos == cur.cell().empty()) {
                        ar = cur.cell();
                        lyxerr << "use whole cell: " << ar << endl;
                } else {
index 9dae426bea037f02f8bb6434e0b0c86f8e7021a2..ba2be2f729adddff8a17a16e66fabd886de89c64 100644 (file)
@@ -177,7 +177,7 @@ int InsetMathScript::dy01(BufferView const & bv, int asc, int des, int what) con
 {
        int dasc = 0;
        int slevel = 0;
-       bool isCharBox = nuc().size() ? isAlphaSymbol(nuc().back()) : false;
+       bool isCharBox = !nuc().empty() ? isAlphaSymbol(nuc().back()) : false;
        if (hasDown()) {
                Dimension const & dimdown = down().dimension(bv);
                dasc = dimdown.ascent();
@@ -271,25 +271,25 @@ int InsetMathScript::dxx(BufferView const & bv) const
 
 int InsetMathScript::nwid(BufferView const & bv) const
 {
-       return nuc().size() ? nuc().dimension(bv).width() : 2;
+       return !nuc().empty() ? nuc().dimension(bv).width() : 2;
 }
 
 
 int InsetMathScript::nasc(BufferView const & bv) const
 {
-       return nuc().size() ? nuc().dimension(bv).ascent() : 5;
+       return !nuc().empty() ? nuc().dimension(bv).ascent() : 5;
 }
 
 
 int InsetMathScript::ndes(BufferView const & bv) const
 {
-       return nuc().size() ? nuc().dimension(bv).descent() : 0;
+       return !nuc().empty() ? nuc().dimension(bv).descent() : 0;
 }
 
 
 int InsetMathScript::nker(BufferView const * bv) const
 {
-       if (nuc().size()) {
+       if (!nuc().empty()) {
                int kerning = nuc().kerning(bv);
                return kerning > 0 ? kerning : 0;
        }
@@ -351,7 +351,7 @@ void InsetMathScript::metrics(MetricsInfo & mi, Dimension & dim) const
 void InsetMathScript::draw(PainterInfo & pi, int x, int y) const
 {
        BufferView & bv = *pi.base.bv;
-       if (nuc().size())
+       if (!nuc().empty())
                nuc().draw(pi, x + dxx(bv), y);
        else {
                nuc().setXY(bv, x + dxx(bv), y);
@@ -380,7 +380,7 @@ void InsetMathScript::metricsT(TextMetricsInfo const & mi, Dimension & dim) cons
 void InsetMathScript::drawT(TextPainter & pain, int x, int y) const
 {
        // FIXME: BROKEN
-       if (nuc().size())
+       if (!nuc().empty())
                nuc().drawT(pain, x + 1, y);
        if (hasUp())
                up().drawT(pain, x + 1, y - 1 /*dy1()*/);
@@ -399,7 +399,7 @@ bool InsetMathScript::hasLimits() const
                return false;
 
        // we can only display limits if the nucleus wants some
-       if (!nuc().size())
+       if (nuc().empty())
                return false;
        if (!nuc().back()->isScriptable())
                return false;
@@ -530,7 +530,7 @@ void InsetMathScript::write(WriteStream & os) const
 {
        MathEnsurer ensurer(os);
 
-       if (nuc().size()) {
+       if (!nuc().empty()) {
                os << nuc();
                //if (nuc().back()->takesLimits()) {
                        if (limits_ == -1)
@@ -545,13 +545,13 @@ void InsetMathScript::write(WriteStream & os) const
                        os << "{}";
        }
 
-       if (hasDown() /*&& down().size()*/)
+       if (hasDown() /*&& !down().empty()*/)
                os << "_{" << down() << '}';
 
-       if (hasUp() /*&& up().size()*/) {
+       if (hasUp() /*&& !up().empty()*/) {
                // insert space if up() is empty or an empty brace inset
                // (see bug 8305)
-               if (os.latex() && (up().size() == 0 ||
+               if (os.latex() && (up().empty() ||
                    (up().size() == 1 && up().back()->asBraceInset() &&
                     up().back()->asBraceInset()->cell(0).empty())))
                        os << "^ {}";
@@ -566,8 +566,8 @@ void InsetMathScript::write(WriteStream & os) const
 
 void InsetMathScript::normalize(NormalStream & os) const
 {
-       bool d = hasDown() && down().size();
-       bool u = hasUp() && up().size();
+       bool d = hasDown() && !down().empty();
+       bool u = hasUp() && !up().empty();
 
        if (u && d)
                os << "[subsup ";
@@ -576,7 +576,7 @@ void InsetMathScript::normalize(NormalStream & os) const
        else if (d)
                os << "[sub ";
 
-       if (nuc().size())
+       if (!nuc().empty())
                os << nuc() << ' ';
        else
                os << "[par]";
@@ -592,21 +592,21 @@ void InsetMathScript::normalize(NormalStream & os) const
 
 void InsetMathScript::maple(MapleStream & os) const
 {
-       if (nuc().size())
+       if (!nuc().empty())
                os << nuc();
-       if (hasDown() && down().size())
+       if (hasDown() && !down().empty())
                os << '[' << down() << ']';
-       if (hasUp() && up().size())
+       if (hasUp() && !up().empty())
                os << "^(" << up() << ')';
 }
 
 
 void InsetMathScript::mathematica(MathematicaStream & os) const
 {
-       bool d = hasDown() && down().size();
-       bool u = hasUp() && up().size();
+       bool d = hasDown() && !down().empty();
+       bool u = hasUp() && !up().empty();
 
-       if (nuc().size()) {
+       if (!nuc().empty()) {
                if (d)
                        os << "Subscript[" << nuc();
                else
@@ -616,7 +616,7 @@ void InsetMathScript::mathematica(MathematicaStream & os) const
        if (u)
                os << "^(" << up() << ')';
 
-       if (nuc().size()) {
+       if (!nuc().empty()) {
                if (d)
                        os << ',' << down() << ']';
        }
@@ -629,8 +629,8 @@ void InsetMathScript::mathematica(MathematicaStream & os) const
 // need to know if we're in a display formula.
 void InsetMathScript::mathmlize(MathStream & os) const
 {
-       bool d = hasDown() && down().size();
-       bool u = hasUp() && up().size();
+       bool d = hasDown() && !down().empty();
+       bool u = hasUp() && !up().empty();
 
        if (u && d)
                os << MTag("msubsup");
@@ -639,7 +639,7 @@ void InsetMathScript::mathmlize(MathStream & os) const
        else if (d)
                os << MTag("msub");
 
-       if (nuc().size())
+       if (!nuc().empty())
                os << MTag("mrow") << nuc() << ETag("mrow");
        else
                os << "<mrow />";
@@ -657,10 +657,10 @@ void InsetMathScript::mathmlize(MathStream & os) const
 
 void InsetMathScript::htmlize(HtmlStream & os) const
 {
-       bool d = hasDown() && down().size();
-       bool u = hasUp() && up().size();
+       bool d = hasDown() && !down().empty();
+       bool u = hasUp() && !up().empty();
 
-       if (nuc().size())
+       if (!nuc().empty())
                os << nuc();
 
        if (u && d)
@@ -677,11 +677,11 @@ void InsetMathScript::htmlize(HtmlStream & os) const
 
 void InsetMathScript::octave(OctaveStream & os) const
 {
-       if (nuc().size())
+       if (!nuc().empty())
                os << nuc();
-       if (hasDown() && down().size())
+       if (hasDown() && !down().empty())
                os << '[' << down() << ']';
-       if (hasUp() && up().size())
+       if (hasUp() && !up().empty())
                os << "^(" << up() << ')';
 }
 
index 44799bac2fed2f8ff9277ec1c0d8d55913e7585a..eef5b4388c4546aff6f65ea5eb7d839801331760 100644 (file)
@@ -64,7 +64,7 @@ void InsetMathXArrow::write(WriteStream & os) const
 {
        MathEnsurer ensurer(os);
        os << '\\' << name_;
-       if (cell(1).size())
+       if (!cell(1).empty())
                os << '[' << cell(1) << ']';
        os << '{' << cell(0) << '}';
 }
index 69227564ee8482c0c5996a372b62973f07b72d73..0cb525c15a0e28b69842dff8dea6d42ec604b850 100644 (file)
@@ -142,9 +142,9 @@ void InsetMathXYArrow::write(WriteStream & os) const
 {
        MathEnsurer ensurer(os);
        os << "\\ar";
-       if (cell(0).size())
+       if (!cell(0).empty())
                os << '[' << cell(0) << ']';
-       if (cell(1).size())
+       if (!cell(1).empty())
                os << (up_ ? '^' : '_') << '{' << cell(1) << '}';
        os << " ";
 }
index fcc9f7705af445c692303fa50f579f59956790ce..e49959a16d3aacf4c33454a9af25c6f34585d4c6 100644 (file)
@@ -149,7 +149,7 @@ void initAutoCorrect()
        string line;
        ifstream is(file.toFilesystemEncoding().c_str());
        while (getline(is, line)) {
-               if (line.size() == 0 || line[0] == '#') {
+               if (line.empty() || line[0] == '#') {
                        //LYXERR(Debug::MATHED, "ignoring line '" << line << '\'');
                        continue;
                }
index 12fb6c190754cd969a81d5cf5a02ceacecbefcdd..2992c41f1d036bfc02ae8c39a656a8f6e80bcaf1 100644 (file)
@@ -339,13 +339,13 @@ void MathData::draw(PainterInfo & pi, int x, int y) const
                docstring s1 = completion.substr(0, uniqueTo);
                docstring s2 = completion.substr(uniqueTo);
                
-               if (s1.size() > 0) {
+               if (!s1.empty()) {
                        f.setColor(Color_inlinecompletion);
                        pi.pain.text(x, y, s1, f);
                        x += mathed_string_width(f, s1);
                }
                
-               if (s2.size() > 0) {
+               if (!s2.empty()) {
                        f.setColor(Color_nonunique_inlinecompletion);
                        pi.pain.text(x, y, s2, f);
                        x += mathed_string_width(f, s2);
index 8d1df06f777ee1e78b3bfa8df57c035d5c939e6f..d3bf7387532a37ad70507cfca827e139475b301f 100644 (file)
@@ -352,7 +352,7 @@ void splitScripts(MathData & ar)
                        continue;
 
                // we must have a nucleus if we only have a superscript
-               if (!script->hasDown() && script->nuc().size() == 0)
+               if (!script->hasDown() && script->nuc().empty())
                        continue;
 
                if (script->nuc().size() == 1) {
@@ -619,7 +619,7 @@ bool testIntegral(MathAtom const & at)
        return
         testIntSymbol(at) ||
                ( at->asScriptInset()
-                 && at->asScriptInset()->nuc().size()
+                 && !at->asScriptInset()->nuc().empty()
                        && testIntSymbol(at->asScriptInset()->nuc().back()) );
 }
 
@@ -719,7 +719,7 @@ bool testSum(MathAtom const & at)
        return
         testSumSymbol(at) ||
                ( at->asScriptInset()
-                 && at->asScriptInset()->nuc().size()
+                 && !at->asScriptInset()->nuc().empty()
                        && testSumSymbol(at->asScriptInset()->nuc().back()) );
 }
 
@@ -800,7 +800,7 @@ bool testDiffItem(MathAtom const & at)
 
 bool testDiffArray(MathData const & ar)
 {
-       return ar.size() && testDiffItem(ar.front());
+       return !ar.empty() && testDiffItem(ar.front());
 }
 
 
@@ -1419,7 +1419,7 @@ void mathmlize(MathData const & dat, MathStream & os)
 {
        MathData ar = dat;
        extractStructure(ar, MATHML);
-       if (ar.size() == 0)
+       if (ar.empty())
                os << "<mrow/>";
        else if (ar.size() == 1)
                os << ar.front();
@@ -1436,7 +1436,7 @@ void htmlize(MathData const & dat, HtmlStream & os)
 {
        MathData ar = dat;
        extractStructure(ar, HTML);
-       if (ar.size() == 0) 
+       if (ar.empty())
                return;
        if (ar.size() == 1) {
                os << ar.front();
index cd9b757a51742385a883a283ccd1d68913d59e8b..1786e81c29d4fd3427314aaf14c843467a3d0ae7 100644 (file)
@@ -465,7 +465,7 @@ void MathMacro::draw(PainterInfo & pi, int x, int y) const
 void MathMacro::drawSelection(PainterInfo & pi, int x, int y) const
 {
        // We may have 0 arguments, but InsetMathNest requires at least one.
-       if (cells_.size() > 0)
+       if (!cells_.empty())
                InsetMathNest::drawSelection(pi, x, y);
 }
 
@@ -507,8 +507,7 @@ bool MathMacro::validName() const
 {
        docstring n = name();
 
-       // empty name?
-       if (n.size() == 0)
+       if (n.empty())
                return false;
 
        // converting back and force doesn't swallow anything?
index 2d36e4d2238f520851dfa306bf19d1bf5f1cf239..8220aa68a636f8691ff616d6acf688659a94ba61 100644 (file)
@@ -994,7 +994,7 @@ void MathMacroTemplate::doDispatch(Cursor & cur, FuncRequest & cmd)
                        commitEditChanges(cur, cur);
                        cur.recordUndoFullDocument();
                        size_t pos = numargs_;
-                       if (arg.size() != 0)
+                       if (!arg.empty())
                                pos = (size_t)convert<int>(arg) - 1; // it is checked for >=0 in getStatus
                        insertParameter(cur, cur, pos);
                }
@@ -1006,7 +1006,7 @@ void MathMacroTemplate::doDispatch(Cursor & cur, FuncRequest & cmd)
                        commitEditChanges(cur, cur);
                        cur.recordUndoFullDocument();
                        size_t pos = numargs_ - 1;
-                       if (arg.size() != 0)
+                       if (!arg.empty())
                                pos = (size_t)convert<int>(arg) - 1; // it is checked for >=0 in getStatus
                        removeParameter(cur, cur, pos);
                }
@@ -1080,7 +1080,7 @@ bool MathMacroTemplate::getStatus(Cursor & /*cur*/, FuncRequest const & cmd,
        switch (cmd.action()) {
                case LFUN_MATH_MACRO_ADD_PARAM: {
                        int num = numargs_ + 1;
-                       if (arg.size() != 0)
+                       if (!arg.empty())
                                num = convert<int>(arg);
                        bool on = (num >= optionals_
                                   && numargs_ < 9 && num <= numargs_ + 1);
@@ -1095,7 +1095,7 @@ bool MathMacroTemplate::getStatus(Cursor & /*cur*/, FuncRequest const & cmd,
                case LFUN_MATH_MACRO_REMOVE_GREEDY_PARAM:
                case LFUN_MATH_MACRO_REMOVE_PARAM: {
                        int num = numargs_;
-                       if (arg.size() != 0)
+                       if (!arg.empty())
                                num = convert<int>(arg);
                        flag.setEnabled(num >= 1 && num <= numargs_);
                        break;
@@ -1266,8 +1266,7 @@ bool MathMacroTemplate::validName() const
 {
        docstring n = name();
 
-       // empty name?
-       if (n.size() == 0)
+       if (n.empty())
                return false;
 
        // converting back and force doesn't swallow anything?
@@ -1316,7 +1315,7 @@ bool MathMacroTemplate::fixNameAndCheckIfValid()
        }
 
        // now it should be valid if anything in the name survived
-       return data.size() > 0;
+       return !data.empty();
 }
 
        
index 9752320095312a75ff1b857d007ee0e679b50c27..1982af3c86c47b2b2e85f59fb367d4a1c9a654c0 100644 (file)
@@ -334,9 +334,9 @@ public:
        ///
        char_type character() const { return char_; }
        ///
-       docstring asString() const { return cs_.size() ? cs_ : docstring(1, char_); }
+       docstring asString() const { return !cs_.empty() ? cs_ : docstring(1, char_); }
        ///
-       docstring asInput() const { return cs_.size() ? '\\' + cs_ : docstring(1, char_); }
+       docstring asInput() const { return !cs_.empty() ? '\\' + cs_ : docstring(1, char_); }
 
 private:
        ///
@@ -350,7 +350,7 @@ private:
 
 ostream & operator<<(ostream & os, Token const & t)
 {
-       if (t.cs().size()) {
+       if (!t.cs().empty()) {
                docstring const & cs = t.cs();
                // FIXME: For some strange reason, the stream operator instanciate
                // a new Token before outputting the contents of t.cs().
@@ -951,7 +951,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        bool up = (t.cat() == catSuper);
                        // we need no new script inset if the last thing was a scriptinset,
                        // which has that script already not the same script already
-                       if (!cell->size())
+                       if (cell->empty())
                                cell->push_back(MathAtom(new InsetMathScript(buf, up)));
                        else if (cell->back()->asScriptInset() &&
                                        !cell->back()->asScriptInset()->has(up))
@@ -1029,7 +1029,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                //
 
                else if (t.cs() == "lyxlock") {
-                       if (cell->size())
+                       if (!cell->empty())
                                cell->back().nucleus()->lock(true);
                }
 
@@ -1377,7 +1377,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                else if (t.cs() == "sqrt") {
                        MathData ar;
                        parse(ar, FLAG_OPTION, mode);
-                       if (ar.size()) {
+                       if (!ar.empty()) {
                                cell->push_back(MathAtom(new InsetMathRoot(buf)));
                                cell->back().nucleus()->cell(0) = ar;
                                parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
@@ -1399,7 +1399,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        // Allowed formats \unit[val]{unit}
                        MathData ar;
                        parse(ar, FLAG_OPTION, mode);
-                       if (ar.size()) {
+                       if (!ar.empty()) {
                                cell->push_back(MathAtom(new InsetMathFrac(buf, InsetMathFrac::UNIT)));
                                cell->back().nucleus()->cell(0) = ar;
                                parse(cell->back().nucleus()->cell(1), FLAG_ITEM, mode);
@@ -1413,7 +1413,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                        // Here allowed formats are \unitfrac[val]{num}{denom}
                        MathData ar;
                        parse(ar, FLAG_OPTION, mode);
-                       if (ar.size()) {
+                       if (!ar.empty()) {
                                cell->push_back(MathAtom(new InsetMathFrac(buf, InsetMathFrac::UNITFRAC, 3)));
                                cell->back().nucleus()->cell(2) = ar;
                        } else {
@@ -1845,10 +1845,10 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                        rem.clear();
                                } else
                                        cmd.clear();
-                       } while (cmd.size());
+                       } while (!cmd.empty());
                }
 
-               else if (t.cs().size()) {
+               else if (!t.cs().empty()) {
                        bool const no_mhchem =
                                (t.cs() == "ce" || t.cs() == "cf")
                                && buf && buf->params().use_package("mhchem") ==
@@ -1979,7 +1979,7 @@ bool Parser::parse1(InsetMathGrid & grid, unsigned flags,
                                        // this fails on \bigg[...\bigg]
                                        //MathData opt;
                                        //parse(opt, FLAG_OPTION, InsetMath::VERBATIM_MODE);
-                                       //if (opt.size()) {
+                                       //if (!opt.empty()) {
                                        //      start = 1;
                                        //      at.nucleus()->cell(0) = opt;
                                        //}
index 7c7fd3ef416328d25ebb9dbedaada3b01075b2e2..0a902b7ef2544bf3b6cdf022fffb883fd748429b 100644 (file)
@@ -1111,13 +1111,13 @@ void RowPainter::paintInlineCompletion(Font const & font)
                swap(c1, c2);
        }
 
-       if (s1.size() > 0) {
+       if (!s1.empty()) {
                f.setColor(c1);
                pi_.pain.text(int(x_), yo_, s1, f);
                x_ += theFontMetrics(font).width(s1);
        }
 
-       if (s2.size() > 0) {
+       if (!s2.empty()) {
                f.setColor(c2);
                pi_.pain.text(int(x_), yo_, s2, f);
                x_ += theFontMetrics(font).width(s2);
index d19c2e39be7aa7396867b98662b76551fcf33619..c937ba3721a1157bd2acff7d0bc754b74b0e614e 100644 (file)
@@ -133,7 +133,7 @@ string const to_local8bit(docstring const & s)
        if (s.empty())
                return string();
        QByteArray const local = toqstr(s).toLocal8Bit();
-       if (local.size() == 0)
+       if (local.isEmpty())
                throw to_local8bit_failure();
        return string(local.begin(), local.end());
 }
index 10f4793ff34c31b3421c89ec4271ac5dade1f957..0b833740d0a31aaa3a3bc6c46b249c88aa8004d5 100644 (file)
@@ -1769,7 +1769,7 @@ public:
             clear();
 
             key_less = other.key_comp();
-            if (other.size() != 0)
+            if (!other.empty())
             {
                 stats.leaves = stats.innernodes = 0;
                 root = copy_recursive(other.root);
@@ -1788,7 +1788,7 @@ public:
           stats( other.stats ),
           key_less( other.key_comp() )
     {
-        if (size() > 0)
+        if (!empty())
         {
             stats.leaves = stats.innernodes = 0;
             root = copy_recursive(other.root);
index e397c32fd75ae9d4621431696b7f8af0c3ad0654..01626f3a500892313a2afbde6d830c93171e0657 100644 (file)
@@ -4384,7 +4384,7 @@ void parse_text(Parser & p, ostream & os, unsigned flags, bool outer,
                        /*
                        string s = t.asInput();
                        string z = p.verbatim_item();
-                       while (p.good() && z != " " && z.size()) {
+                       while (p.good() && z != " " && !z.empty()) {
                                //cerr << "read: " << z << endl;
                                s += z;
                                z = p.verbatim_item();