# # # patch "HACKING" # from [a94eadea2457641d2d23ddd8dab732b207197bfb] # to [f28fd6981f93583e624a512cc0369af008e54e31] # # patch "NEWS" # from [110c3ae4353ee63cbad27ee3d31c2e71f2cd880d] # to [47e5ef8bcaa0de6679cad6e658eac1a6e53bae6d] # # patch "asciik.cc" # from [8d87e9368e3f3ebd63df11e12610ac90ac2ee4e5] # to [19d8611c0c65c40e61edbc41f6a273ee00a3e7d5] # # patch "automate.cc" # from [9a700bfc52a6a21e3b5d2d930ad634d455dafcae] # to [598a04952daffa804d60dde204967b20e17fc37a] # # patch "cert.cc" # from [ea80fd9e75d015c5b99450a997c461cc36c708ae] # to [0bc1e3ef1f3815c8ec8aca3316d2438183fc6e3e] # # patch "cmd_automate.cc" # from [d6b6339f3d9fa5cba017d7316beecf4aa193c9a2] # to [31490dcba1e859909b03f69fedfcc7ffe1ca0faa] # # patch "cmd_diff_log.cc" # from [fd455eacd212d63aa201035e9417b9cf726f498b] # to [509da14568d804c8e3fb741cc676f0979fe33e6f] # # patch "cmd_files.cc" # from [4476e4cbb2f0c770c4b043a0f507c76d739c6d0a] # to [841a84d62213f19f5b7cd9bc8582a506ec6058c0] # # patch "cmd_key_cert.cc" # from [bc79d0edf706e78a386555f6cc45c033424356fb] # to [bf2253ced263b560310d15589503376b57cf9625] # # patch "cmd_list.cc" # from [5fa3e7c75de40b0315ae337be019c202a039a67b] # to [e83d74b0940588a053b816195b0b48f6f3303147] # # patch "cmd_merging.cc" # from [c00d7dd2a1dd4dda7da812ae6216b6ee391238b9] # to [bdcb87dfaf55bd7d99090ff3bee7d12b4a49ce28] # # patch "cmd_netsync.cc" # from [34174bb7ce83722d7a9859b7065c40243ca0ba75] # to [6076270daf87ef2173729846525a80aebc0322b4] # # patch "cmd_ws_commit.cc" # from [77b18e38145f345b0eb65b73cc05619464a8fc59] # to [f19eb71e76506b5ac8a706f610e6a34b595266a1] # # patch "commands.cc" # from [0cf90848baf2600e9f60d74d642af0202b8ae23b] # to [8efefe3c8beba45e073c7312345da580d459de4a] # # patch "database.cc" # from [9ca8614df165a0bacf041d38dd0e8f22deab9c72] # to [835e3a15821c38e21fda2407e3fe361cb885a441] # # patch "diff_patch.cc" # from [211424b28fdc3a5dcdae5a781feea97e1e915326] # to [124940fab163d7d820e9d229a9b2f947adbe7b33] # # patch "globish.cc" # from [942cfee157ecd028adfbe0a81f2a49b74aa8b1fd] # to [a25133bce26322aa0151d7e6420db17833283761] # # patch "keys.cc" # from [eed2855394e23d0bce4b7a0de434c9731236dd5b] # to [2abf0e69af26366c6662d5fec284abd51c97a977] # # patch "lua_hooks.cc" # from [e93b511c04660956edd432fda230877ca3c6fc2b] # to [0476cf2512e471ca31d9a3b185968487fbeb9e8e] # # patch "monotone.cc" # from [f07f41bff548629d5e9d178acfeb1d2f23385f6c] # to [c675c913e89752c4e38fc3e0410a40e7157f42ef] # # patch "mt_version.cc" # from [3e984b954e17538a14e1ece58493fcb3afef8846] # to [271946e05e232569f97b685e3354819a81683643] # # patch "netsync.cc" # from [f5e514d79d677707147093b076dc8d232aabc07c] # to [faa9a58eb3dd3f07ec771969251ba8c5c8f2d91d] # # patch "packet.cc" # from [2d7793fd8c7172a6cc085b2c6bfe16159fe7e96d] # to [a2f1919b3d48da52fd5ca1b2c7b4465606a7f1d3] # # patch "paths.cc" # from [dde6659e387c8890c96278ea29e3196bdf588139] # to [62dd47ddddd4fc2b44899232c0ef05a0e47e10e6] # # patch "randomfile.hh" # from [b6b680a21c57b786686cedc7330d3ecbf847c924] # to [86995b5fde62b718b35ef8b1231036734a5b950b] # # patch "rcs_import.cc" # from [a7f8196795b4e5a45d74be47cf4df22e995f4659] # to [295ce31bb7a349f1c0a6b534c2285017ee4cc805] # # patch "rev_height.hh" # from [b1e48b09b2982ee038344cddfe54768c4f3675a8] # to [6b528fe9d4944ba8758676e320e658ae945eeed9] # # patch "roster.cc" # from [9cebdc581039f2d117abc2c90c4230b2c9635166] # to [8da91335dd3fc3b44dd18107fc213696323725d3] # # patch "roster_merge.cc" # from [8719a10632e29c70df2f8e17e91a13607e40d258] # to [21d6022f920396114975ce40077d425a88a08bb0] # # patch "schema_migration.cc" # from [e12c30bd63024372cfa3ac533a2261272374b180] # to [3949185f804a860857b4e59056e5f46c3c2ab349] # # patch "selectors.cc" # from [0ad775938f68b07b748a6a5b671dbbd464d23c38] # to [0992aac2e54e83d7fefbbf43d0d77c3f5ee40089] # # patch "simplestring_xform.cc" # from [dcaa75eb0ed67ddc119ef62f06c21bd7d13bf5cb] # to [0ce9a86370da9e0043729c1bae322655035694be] # # patch "string_queue.cc" # from [34880af1af20cae04a527f370db60dd94ac6e97f] # to [39f987fc625eb0f43ba86c794b40ad008fc5114e] # # patch "tester.cc" # from [144b85b2298949c9bbc303644bf972c36fd80c26] # to [7d7860782ceb19fec915b63ab6d7b3bebf829502] # # patch "ui.cc" # from [31589a9e86d23d92cb4f87b310c6eb920d026db6] # to [8c499aa720bdce5eeb46deecea1cb94e0c8a2e3b] # # patch "vocab.cc" # from [321f9118a2194a0a8b3314af70836e4ac760039f] # to [164af638b42b1255dd2cffa88b56803c98a004fe] # # patch "work.cc" # from [0ef66673796d2a408587d70530944a5a8747d488] # to [39fcc1fec0b072c6ec588d59586b91b42b8e824c] # # patch "xdelta.cc" # from [a5a5ce3a1ed7c9dead79c526e382237697d54c04] # to [3e042fc714973dc387d2dbb3c3848e67b49488f0] # ============================================================ --- HACKING a94eadea2457641d2d23ddd8dab732b207197bfb +++ HACKING f28fd6981f93583e624a512cc0369af008e54e31 @@ -354,7 +354,7 @@ to do something it is unable to. e.g. User naughtiness handles error conditions where the user has asked monotone to do something it is unable to. e.g. - N(completions.size() != 0, + N(!completions.empty(), F("no match for selection '%s'") % str); Error conditions handle most other error cases, where monotone is unable to ============================================================ --- NEWS 110c3ae4353ee63cbad27ee3d31c2e71f2cd880d +++ NEWS 47e5ef8bcaa0de6679cad6e658eac1a6e53bae6d @@ -17,6 +17,10 @@ would reinitialize the database. This was rather slow, so monotone will now keep the database open between commands. + - Small performance gains especially for annotate by replacing + 'size() == 0' and similar checks with the faster 'empty()' + STL method. + New features - New 'mtn ls duplicates' command which lets you list ============================================================ --- asciik.cc 8d87e9368e3f3ebd63df11e12610ac90ac2ee4e5 +++ asciik.cc 19d8611c0c65c40e61edbc41f6a273ee00a3e7d5 @@ -245,7 +245,7 @@ asciik::draw(size_t const curr_items, if (num_lines < 2) lines.push_back(string("")); // ignore empty lines at the end - while ((num_lines > 2) && (lines[num_lines - 1].size() == 0)) + while ((num_lines > 2) && (lines[num_lines - 1].empty())) --num_lines; // prints it out @@ -314,7 +314,7 @@ asciik::try_draw(vector con preservation_crosses.begin(), preservation_crosses.end(), parent_crosses.begin(), parent_crosses.end(), insert_iterator >(intersection_crosses, intersection_crosses.begin())); - if (intersection_crosses.size() > 0) + if (!intersection_crosses.empty()) return false; set > links(preservation_links); @@ -360,7 +360,7 @@ asciik::print(revision_id const & rev, curr_row = no_ghost; else if (try_draw(next_row, curr_loc, parents, annotation)) curr_row = next_row; - else if (new_revs.size() == 0) // this line has disappeared + else if (new_revs.empty()) // this line has disappeared { vector extra_ghost(next_row); I(curr_loc < extra_ghost.size()); ============================================================ --- automate.cc 9a700bfc52a6a21e3b5d2d930ad634d455dafcae +++ automate.cc 598a04952daffa804d60dde204967b20e17fc37a @@ -966,7 +966,7 @@ inventory_determine_changes(inventory_it if (item.new_node.type == path::file) changes.push_back("content"); - if (item.new_node.attrs.size() > 0) + if (!item.new_node.attrs.empty()) changes.push_back("attrs"); } } @@ -2150,7 +2150,7 @@ CMD_AUTOMATE(get_db_variables, N_("[DOMA if (cur_domain != i->first.first) { // check if we need to print a previous stanza - if (st.entries.size() > 0) + if (!st.entries.empty()) { pr.print_stanza(st); st.entries.clear(); ============================================================ --- cert.cc ea80fd9e75d015c5b99450a997c461cc36c708ae +++ cert.cc 0bc1e3ef1f3815c8ec8aca3316d2438183fc6e3e @@ -409,7 +409,7 @@ guess_branch(options & opts, project_t & set branches; project.get_revision_branches(ident, branches); - N(branches.size() != 0, + N(!branches.empty(), F("no branch certs found for revision %s, " "please provide a branch name") % ident); ============================================================ --- cmd_automate.cc d6b6339f3d9fa5cba017d7316beecf4aa193c9a2 +++ cmd_automate.cc 31490dcba1e859909b03f69fedfcc7ffe1ca0faa @@ -87,7 +87,7 @@ CMD_AUTOMATE(interface_version, "", "", options::opts::none) { - N(args.size() == 0, + N(args.empty(), F("no arguments needed")); output << interface_version << '\n'; @@ -343,7 +343,7 @@ CMD_AUTOMATE(stdio, "", "", options::opts::automate_stdio_size) { - N(args.size() == 0, + N(args.empty(), F("no arguments needed")); database db(app); @@ -384,7 +384,7 @@ CMD_AUTOMATE(stdio, "", set< command_id > matches = CMD_REF(automate)->complete_command(id); - if (matches.size() == 0) + if (matches.empty()) { N(false, F("no completions for this command")); } @@ -475,7 +475,7 @@ LUAEXT(mtn_automate, ) set< commands::command_id > matches = CMD_REF(automate)->complete_command(id); - if (matches.size() == 0) + if (matches.empty()) { N(false, F("no completions for this command")); } ============================================================ --- cmd_diff_log.cc fd455eacd212d63aa201035e9417b9cf726f498b +++ cmd_diff_log.cc 509da14568d804c8e3fb741cc676f0979fe33e6f @@ -365,7 +365,7 @@ prepare_diff(app_state & app, N(app.opts.revision_selectors.size() <= 2, F("more than two revisions given")); - if (app.opts.revision_selectors.size() == 0) + if (app.opts.revision_selectors.empty()) { roster_t old_roster, restricted_roster, new_roster; revision_id old_rid; @@ -509,7 +509,7 @@ CMD(diff, "diff", "di", CMD_REF(informat vector lines; split_into_lines(summary(), lines); cout << "#\n"; - if (summary().size() > 0) + if (!summary().empty()) { cout << revs << "#\n"; for (vector::iterator i = lines.begin(); @@ -644,7 +644,7 @@ CMD(log, "log", "", CMD_REF(informative) frontier_t frontier(rev_cmp(!(next>0))); revision_id first_rid; // for mapping paths to node ids when restricted - if (app.opts.from.size() == 0) + if (app.opts.from.empty()) { workspace work(app, F("try passing a --from revision to start at")); @@ -680,10 +680,10 @@ CMD(log, "log", "", CMD_REF(informative) node_restriction mask; - if (args.size() > 0) + if (!args.empty()) { // User wants to trace only specific files - if (app.opts.from.size() == 0) + if (app.opts.from.empty()) { workspace work(app); roster_t new_roster; ============================================================ --- cmd_files.cc 4476e4cbb2f0c770c4b043a0f507c76d739c6d0a +++ cmd_files.cc 841a84d62213f19f5b7cd9bc8582a506ec6058c0 @@ -146,7 +146,7 @@ CMD(annotate, "annotate", "", CMD_REF(in L(FL("annotate file '%s'") % file); roster_t roster; - if (app.opts.revision_selectors.size() == 0) + if (app.opts.revision_selectors.empty()) { // What this _should_ do is calculate the current workspace roster // and/or revision and hand that to do_annotate. This should just @@ -198,19 +198,15 @@ CMD(identify, "identify", "", CMD_REF(de "one from the standard input is calculated."), options::opts::none) { - if (!(args.size() == 0 || args.size() == 1)) + if (args.size() > 1) throw usage(execid); data dat; - if (args.size() == 1) - { - read_data_for_command_line(idx(args, 0), dat); - } + if (args.empty()) + read_data_stdin(dat); else - { - read_data_stdin(dat); - } + read_data_for_command_line(idx(args, 0), dat); id ident; calculate_ident(dat, ident); @@ -296,7 +292,7 @@ CMD(cat, "cat", "", CMD_REF(informative) database db(app); revision_id rid; - if (app.opts.revision_selectors.size() == 0) + if (app.opts.revision_selectors.empty()) { workspace work(app); parent_map parents; @@ -363,7 +359,7 @@ CMD_AUTOMATE(get_file_of, N_("FILENAME") database db(app); revision_id rid; - if (app.opts.revision_selectors.size() == 0) + if (app.opts.revision_selectors.empty()) { workspace work(app); ============================================================ --- cmd_key_cert.cc bc79d0edf706e78a386555f6cc45c033424356fb +++ cmd_key_cert.cc bf2253ced263b560310d15589503376b57cf9625 @@ -122,7 +122,7 @@ CMD(ssh_agent_export, "ssh_agent_export" rsa_keypair_id id; get_user_key(app.opts, app.lua, db, keys, id); - if (args.size() == 0) + if (args.empty()) keys.export_key_for_agent(id, cout); else { ============================================================ --- cmd_list.cc 5fa3e7c75de40b0315ae337be019c202a039a67b +++ cmd_list.cc e83d74b0940588a053b816195b0b48f6f3303147 @@ -136,7 +136,7 @@ CMD(certs, "certs", "", CMD_REF(list), " vector lines; split_into_lines(washed, lines); - std::string value_first_line = lines.size() > 0 ? idx(lines, 0) : ""; + std::string value_first_line = lines.empty() ? "" : idx(lines, 0); cout << string(guess_terminal_width(), '-') << '\n' << (i18n_format(str) @@ -149,7 +149,7 @@ CMD(certs, "certs", "", CMD_REF(list), " cout << (i18n_format(extra_str) % idx(lines, i)); } - if (certs.size() > 0) + if (!certs.empty()) cout << '\n'; guard.commit(); @@ -161,7 +161,7 @@ CMD(duplicates, "duplicates", "", CMD_RE "", options::opts::revision) { - if (args.size() != 0) + if (!args.empty()) throw usage(execid); revision_id rev_id; @@ -172,7 +172,7 @@ CMD(duplicates, "duplicates", "", CMD_RE N(app.opts.revision_selectors.size() <= 1, F("more than one revision given")); - if (app.opts.revision_selectors.size() == 0) + if (app.opts.revision_selectors.empty()) { workspace work(app); temp_node_id_source nis; @@ -302,7 +302,7 @@ CMD(keys, "keys", "", CMD_REF(list), "[P } } - if (pubkeys.size() > 0) + if (!pubkeys.empty()) { cout << "\n[public keys]\n"; for (map::iterator i = pubkeys.begin(); @@ -333,7 +333,7 @@ CMD(keys, "keys", "", CMD_REF(list), "[P cout << '\n'; } - if (privkeys.size() > 0) + if (!privkeys.empty()) { cout << "\n[private keys]\n"; for (vector::iterator i = privkeys.begin(); @@ -358,10 +358,9 @@ CMD(keys, "keys", "", CMD_REF(list), "[P } } - if (pubkeys.size() == 0 && - privkeys.size() == 0) + if (pubkeys.empty() && privkeys.empty()) { - if (args.size() == 0) + if (args.empty()) P(F("no keys found")); else W(F("no keys found matching '%s'") % idx(args, 0)()); @@ -400,7 +399,7 @@ CMD(epochs, "epochs", "", CMD_REF(list), map epochs; db.get_epochs(epochs); - if (args.size() == 0) + if (args.empty()) { for (map::const_iterator i = epochs.begin(); @@ -447,7 +446,7 @@ CMD(vars, "vars", "", CMD_REF(list), "[D { bool filterp; var_domain filter; - if (args.size() == 0) + if (args.empty()) { filterp = false; } @@ -678,7 +677,7 @@ CMD_AUTOMATE(keys, "", "", options::opts::none) { - N(args.size() == 0, + N(args.empty(), F("no arguments needed")); database db(app); ============================================================ --- cmd_merging.cc c00d7dd2a1dd4dda7da812ae6216b6ee391238b9 +++ cmd_merging.cc bdcb87dfaf55bd7d99090ff3bee7d12b4a49ce28 @@ -128,7 +128,7 @@ pick_branch_for_update(options & opts, d } else { - I(branches.size() == 0); + I(branches.empty()); W(F("target revision not in any branch\n" "next commit will use branch %s") % opts.branchname); @@ -145,7 +145,7 @@ CMD(update, "update", "", CMD_REF(worksp "If not, update the workspace to the head of the branch."), options::opts::branch | options::opts::revision) { - if (args.size() > 0) + if (!args.empty()) throw usage(execid); if (app.opts.revision_selectors.size() > 1) @@ -171,7 +171,7 @@ CMD(update, "update", "", CMD_REF(worksp F("cannot determine branch for update")); revision_id chosen_rid; - if (app.opts.revision_selectors.size() == 0) + if (app.opts.revision_selectors.empty()) { P(F("updating along branch '%s'") % app.opts.branchname); set candidates; @@ -404,7 +404,7 @@ find_heads_to_merge(database & db, set 0); + I(!ancestors.empty()); // Take the first ancestor from the above set. return heads_for_ancestor[*ancestors.begin()]; @@ -423,7 +423,7 @@ CMD(merge, "merge", "", CMD_REF(tree), " key_store keys(app); project_t project(db); - if (args.size() != 0) + if (!args.empty()) throw usage(execid); N(app.opts.branchname() != "", @@ -433,7 +433,7 @@ CMD(merge, "merge", "", CMD_REF(tree), " project.get_branch_heads(app.opts.branchname, heads, app.opts.ignore_suspend_certs); - N(heads.size() != 0, F("branch '%s' is empty") % app.opts.branchname); + N(!heads.empty(), F("branch '%s' is empty") % app.opts.branchname); if (heads.size() == 1) { P(F("branch '%s' is already merged") % app.opts.branchname); @@ -955,7 +955,7 @@ CMD_AUTOMATE(show_conflicts, N_("[LEFT_R project_t project(db); revision_id l_id, r_id; - if (args.size() == 0) + if (args.empty()) { // get ids from heads N(app.opts.branchname() != "", @@ -1187,7 +1187,7 @@ CMD(heads, "heads", "", CMD_REF(tree), " options::opts::branch) { set heads; - if (args.size() != 0) + if (!args.empty()) throw usage(execid); N(app.opts.branchname() != "", @@ -1199,7 +1199,7 @@ CMD(heads, "heads", "", CMD_REF(tree), " project.get_branch_heads(app.opts.branchname, heads, app.opts.ignore_suspend_certs); - if (heads.size() == 0) + if (heads.empty()) P(F("branch '%s' is empty") % app.opts.branchname); else if (heads.size() == 1) P(F("branch '%s' is currently merged:") % app.opts.branchname); @@ -1220,7 +1220,7 @@ CMD(get_roster, "get_roster", "", CMD_RE roster_t roster; marking_map mm; - if (args.size() == 0) + if (args.empty()) { parent_map parents; temp_node_id_source nis; @@ -1231,7 +1231,7 @@ CMD(get_roster, "get_roster", "", CMD_RE work.get_current_roster_shape(db, nis, roster); work.update_current_roster_from_filesystem(roster); - if (parents.size() == 0) + if (parents.empty()) { mark_roster_with_no_parents(rid, roster, mm); } ============================================================ --- cmd_netsync.cc 34174bb7ce83722d7a9859b7065c40243ca0ba75 +++ cmd_netsync.cc 6076270daf87ef2173729846525a80aebc0322b4 @@ -395,12 +395,12 @@ CMD(clone, "clone", "", CMD_REF(network) transaction_guard guard(db, false); - if (app.opts.revision_selectors.size() == 0) + if (app.opts.revision_selectors.empty()) { set heads; project.get_branch_heads(branchname, heads, app.opts.ignore_suspend_certs); - N(heads.size() > 0, + N(!heads.empty(), F("branch '%s' is empty") % branchname); if (heads.size() > 1) { ============================================================ --- cmd_ws_commit.cc 77b18e38145f345b0eb65b73cc05619464a8fc59 +++ cmd_ws_commit.cc f19eb71e76506b5ac8a706f610e6a34b595266a1 @@ -612,7 +612,7 @@ CMD(checkout, "checkout", "co", CMD_REF( if (args.size() > 1 || app.opts.revision_selectors.size() > 1) throw usage(execid); - if (app.opts.revision_selectors.size() == 0) + if (app.opts.revision_selectors.empty()) { // use branch head revision N(!app.opts.branchname().empty(), @@ -621,7 +621,7 @@ CMD(checkout, "checkout", "co", CMD_REF( set heads; project.get_branch_heads(app.opts.branchname, heads, app.opts.ignore_suspend_certs); - N(heads.size() > 0, + N(!heads.empty(), F("branch '%s' is empty") % app.opts.branchname); if (heads.size() > 1) { @@ -657,7 +657,7 @@ CMD(checkout, "checkout", "co", CMD_REF( { bool checkout_dot = false; - if (args.size() == 0) + if (args.empty()) { // No checkout dir specified, use branch name for dir. N(!app.opts.branchname().empty(), @@ -865,7 +865,7 @@ CMD_AUTOMATE(get_attributes, N_("PATH"), "", options::opts::none) { - N(args.size() > 0, + N(!args.empty(), F("wrong argument count")); database db(app); @@ -1405,7 +1405,7 @@ CMD_NO_WORKSPACE(import, "import", "", C P(F("choose one with '%s import -r'") % ui.prog_name); E(false, F("branch %s has multiple heads") % app.opts.branchname); } - if (heads.size() > 0) + if (!heads.empty()) ident = *(heads.begin()); } ============================================================ --- commands.cc 0cf90848baf2600e9f60d74d642af0202b8ae23b +++ commands.cc 8efefe3c8beba45e073c7312345da580d459de4a @@ -607,7 +607,7 @@ namespace commands out << string(colabstract - col, ' '); col = colabstract; string desc(abstract); - if (subcommands.size() > 0) + if (!subcommands.empty()) { desc += " (" + subcommands + ')'; } @@ -617,7 +617,7 @@ namespace commands static void explain_children(command::children_set const & children, ostream & out) { - I(children.size() > 0); + I(!children.empty()); vector< command const * > sorted; @@ -666,7 +666,7 @@ namespace commands << "\n\n"; else { - if (cmd->children().size() > 0) + if (!cmd->children().empty()) out << format_text(F("Subcommands of '%s %s':") % ui.prog_name % visibleid) << "\n\n"; @@ -679,7 +679,7 @@ namespace commands // Print command parameters. string params = cmd->params(); split_into_lines(params, lines); - if (lines.size() > 0) + if (!lines.empty()) { for (vector::const_iterator j = lines.begin(); j != lines.end(); ++j) @@ -1036,14 +1036,14 @@ UNIT_TEST(commands, command_complete_com { command_id id = make_command_id("foo"); set< command_id > matches = CMD_REF(top)->complete_command(id); - UNIT_TEST_REQUIRE(matches.size() == 0); + UNIT_TEST_REQUIRE(matches.empty()); } // Non-existent multi-word identifier. { command_id id = make_command_id("foo bar"); set< command_id > matches = CMD_REF(top)->complete_command(id); - UNIT_TEST_REQUIRE(matches.size() == 0); + UNIT_TEST_REQUIRE(matches.empty()); } // Single-word identifier with one match. Exact matches are found ============================================================ --- database.cc 9ca8614df165a0bacf041d38dd0e8f22deab9c72 +++ database.cc 835e3a15821c38e21fda2407e3fe361cb885a441 @@ -2302,7 +2302,7 @@ database::has_rev_height(rev_height cons imp->fetch(res, one_col, any_rows, query("SELECT height FROM heights WHERE height = ?") % blob(height())); - I((res.size() == 1) || (res.size() == 0)); + I((res.size() == 1) || (res.empty())); return res.size() == 1; } @@ -2666,7 +2666,7 @@ database::public_key_exists(id const & h imp->fetch(res, one_col, any_rows, query("SELECT id FROM public_keys WHERE hash = ?") % blob(hash())); - I((res.size() == 1) || (res.size() == 0)); + I((res.size() == 1) || (res.empty())); if (res.size() == 1) return true; return false; @@ -2679,7 +2679,7 @@ database::public_key_exists(rsa_keypair_ imp->fetch(res, one_col, any_rows, query("SELECT id FROM public_keys WHERE id = ?") % text(id())); - I((res.size() == 1) || (res.size() == 0)); + I((res.size() == 1) || (res.empty())); if (res.size() == 1) return true; return false; @@ -2846,7 +2846,7 @@ database_impl::cert_exists(cert const & fetch(res, 1, any_rows, q); - I(res.size() == 0 || res.size() == 1); + I(res.empty() || res.size() == 1); return res.size() == 1; } @@ -3165,7 +3165,7 @@ database::revision_cert_exists(revision_ "FROM revision_certs " "WHERE hash = ?") % blob(hash.inner()())); - I(res.size() == 0 || res.size() == 1); + I(res.empty() || res.size() == 1); return (res.size() == 1); } @@ -3434,7 +3434,7 @@ database::epoch_exists(epoch_id const & imp->fetch(res, one_col, any_rows, query("SELECT hash FROM branch_epochs WHERE hash = ?") % blob(eid.inner()())); - I(res.size() == 1 || res.size() == 0); + I(res.size() == 1 || res.empty()); return res.size() == 1; } ============================================================ --- diff_patch.cc 211424b28fdc3a5dcdae5a781feea97e1e915326 +++ diff_patch.cc 124940fab163d7d820e9d229a9b2f947adbe7b33 @@ -1072,7 +1072,7 @@ void unidiff_hunk_writer::flush_hunk(siz void unidiff_hunk_writer::flush_hunk(size_t pos) { - if (hunk.size() > 0) + if (!hunk.empty()) { // insert trailing context size_t a_pos = a_begin + a_len; ============================================================ --- globish.cc 942cfee157ecd028adfbe0a81f2a49b74aa8b1fd +++ globish.cc a25133bce26322aa0151d7e6420db17833283761 @@ -71,7 +71,7 @@ compile_charclass(string const & pat, st } // A dash at the beginning or end of the pattern is literal. else if (*p == '-' - && in_class.size() != 0 + && !in_class.empty() && p+1 != pat.end() && p[1] != ']') { @@ -126,7 +126,7 @@ compile_charclass(string const & pat, st N(p != pat.end(), F("invalid pattern '%s': unmatched '['") % pat); - N(in_class.size() != 0, + N(!in_class.empty(), F("invalid pattern '%s': empty character class") % pat); // minor optimization: one-element non-inverted character class becomes ============================================================ --- keys.cc eed2855394e23d0bce4b7a0de434c9731236dd5b +++ keys.cc 2abf0e69af26366c6662d5fec284abd51c97a977 @@ -129,7 +129,7 @@ get_user_key(options const & opts, lua_h { vector all_privkeys; keys.get_key_ids(all_privkeys); - N(all_privkeys.size() > 0, + N(!all_privkeys.empty(), F("you have no private key to make signatures with\n" "perhaps you need to 'genkey '")); N(all_privkeys.size() < 2, ============================================================ --- lua_hooks.cc e93b511c04660956edd432fda230877ca3c6fc2b +++ lua_hooks.cc 0476cf2512e471ca31d9a3b185968487fbeb9e8e @@ -591,7 +591,7 @@ lua_hooks::hook_get_default_command_opti ll.extract_str(arg).pop(); args.push_back(arg_type(arg)); } - return ll.ok() && args.size() > 0; + return ll.ok() && !args.empty(); } bool ============================================================ --- monotone.cc f07f41bff548629d5e9d178acfeb1d2f23385f6c +++ monotone.cc c675c913e89752c4e38fc3e0410a40e7157f42ef @@ -233,7 +233,7 @@ cpp_main(int argc, char ** argv) // check if the user specified default arguments for this command args_vector default_args; - if (cmd.size() > 0 && app.lua.hook_get_default_command_options(cmd, default_args)) + if (!cmd.empty() && app.lua.hook_get_default_command_options(cmd, default_args)) optset.from_command_line(default_args, false); if (workspace::found) ============================================================ --- mt_version.cc 3e984b954e17538a14e1ece58493fcb3afef8846 +++ mt_version.cc 271946e05e232569f97b685e3354819a81683643 @@ -36,7 +36,7 @@ CMD_NO_WORKSPACE(version, "version", "", "", options::opts::full) { - N(args.size() == 0, + N(args.empty(), F("no arguments allowed")); string version; ============================================================ --- netsync.cc f5e514d79d677707147093b076dc8d232aabc07c +++ netsync.cc faa9a58eb3dd3f07ec771969251ba8c5c8f2d91d @@ -796,7 +796,7 @@ session::mk_nonce() id session::mk_nonce() { - I(this->saved_nonce().size() == 0); + I(this->saved_nonce().empty()); char buf[constants::merkle_hash_length_in_bytes]; Botan::Global_RNG::randomize(reinterpret_cast(buf), constants::merkle_hash_length_in_bytes); @@ -1356,7 +1356,7 @@ session::process_hello_cmd(rsa_keypair_i id const & nonce) { I(!this->received_remote_key); - I(this->saved_nonce().size() == 0); + I(this->saved_nonce().empty()); if (use_transport_auth) { @@ -2443,7 +2443,7 @@ build_stream_to_server(options & opts, l if (info.client.use_argv) { - I(info.client.argv.size() > 0); + I(!info.client.argv.empty()); string cmd = info.client.argv[0]; info.client.argv.erase(info.client.argv.begin()); return shared_ptr ============================================================ --- packet.cc 2d7793fd8c7172a6cc085b2c6bfe16159fe7e96d +++ packet.cc a2f1919b3d48da52fd5ca1b2c7b4465606a7f1d3 @@ -129,7 +129,7 @@ namespace } void validate_base64(string const & s) const { - E(s.size() > 0 + E(!s.empty() && s.find_first_not_of(constants::legal_base64_bytes) == string::npos, F("malformed packet: invalid base64 block")); } @@ -140,13 +140,13 @@ namespace } void validate_key(string const & k) const { - E(k.size() > 0 + E(!k.empty() && k.find_first_not_of(constants::legal_key_name_bytes) == string::npos, F("malformed packet: invalid key name")); } void validate_certname(string const & cn) const { - E(cn.size() > 0 + E(!cn.empty() && cn.find_first_not_of(constants::legal_cert_name_bytes) == string::npos, F("malformed packet: invalid cert name")); } @@ -154,7 +154,7 @@ namespace { string next; iss >> next; - E(next.size() == 0, + E(next.empty(), F("malformed packet: too many arguments in header")); } @@ -196,11 +196,11 @@ namespace static void read_rest(istream& in, string& dest) { - while( true ) + while (true) { string t; in >> t; - if( t.size() == 0 ) break; + if (t.empty()) break; dest += t; } } ============================================================ --- paths.cc dde6659e387c8890c96278ea29e3196bdf588139 +++ paths.cc 62dd47ddddd4fc2b44899232c0ef05a0e47e10e6 @@ -227,7 +227,7 @@ in_bookkeeping_dir(string const & path) static inline bool in_bookkeeping_dir(string const & path) { - if (path.size() == 0 || (path[0] != '_')) + if (path.empty() || (path[0] != '_')) return false; if (path.size() == 1 || (path[1] != 'M' && path[1] != 'm')) return false; @@ -271,7 +271,7 @@ normalize_path(string const & in) leader = "/"; inT = inT.substr(1); - if (inT.size() > 0 && inT[0] == '/') + if (!inT.empty() && inT[0] == '/') { // if there are exactly two slashes at the beginning they // are both preserved. three or more are the same as one. @@ -301,7 +301,7 @@ normalize_path(string const & in) #endif I(!is_absolute_here(inT)); - if (inT.size() == 0) + if (inT.empty()) return leader; } ============================================================ --- randomfile.hh b6b680a21c57b786686cedc7330d3ecbf847c924 +++ randomfile.hh 86995b5fde62b718b35ef8b1231036734a5b950b @@ -31,7 +31,7 @@ struct file_randomizer return static_cast(rng.uniform(lines.size())); else { - if (lines.size() == 0) + if (lines.empty()) return 0; else return static_cast(rng.uniform(lines.size() - 1)); ============================================================ --- rcs_import.cc a7f8196795b4e5a45d74be47cf4df22e995f4659 +++ rcs_import.cc 295ce31bb7a349f1c0a6b534c2285017ee4cc805 @@ -844,7 +844,7 @@ cvs_history::push_branch(string const & shared_ptr branch; string bname = base_branch + "." + branch_name; - I(stk.size() > 0); + I(!stk.empty()); if (private_branch) { @@ -1231,7 +1231,7 @@ import_cvs_repo(project_t & project, ticker n_revs(_("revisions"), "r", 1); - while (cvs.branches.size() > 0) + while (!cvs.branches.empty()) { transaction_guard guard(project.db); map >::const_iterator i = cvs.branches.begin(); ============================================================ --- rev_height.hh b1e48b09b2982ee038344cddfe54768c4f3675a8 +++ rev_height.hh 6b528fe9d4944ba8758676e320e658ae945eeed9 @@ -25,7 +25,7 @@ public: rev_height child_height(u32 nr) const; static rev_height root_height(); - bool valid() const { return d.size() > 0; } + bool valid() const { return !d.empty(); } bool operator ==(rev_height const & other) const { ============================================================ --- roster.cc 9cebdc581039f2d117abc2c90c4230b2c9635166 +++ roster.cc 8da91335dd3fc3b44dd18107fc213696323725d3 @@ -1867,8 +1867,8 @@ namespace { // passed to this function is a temp_node_id_source, then we are being // called from get_current_roster_shape, and we should not attempt to // verify that these rosters match as far as content IDs. - if (left_cs.deltas_applied.size() == 0 - && right_cs.deltas_applied.size() == 0 + if (left_cs.deltas_applied.empty() + && right_cs.deltas_applied.empty() && typeid(nis) == typeid(temp_node_id_source)) I(equal_shapes(new_roster, from_right_r)); else @@ -2822,7 +2822,7 @@ do_testing_on_one_roster(roster_t const { if (!r.has_root()) { - I(r.all_nodes().size() == 0); + I(r.all_nodes().empty()); // not much testing to be done on an empty roster -- can't iterate over // it or read/write it. return; ============================================================ --- roster_merge.cc 8719a10632e29c70df2f8e17e91a13607e40d258 +++ roster_merge.cc 21d6022f920396114975ce40077d425a88a08bb0 @@ -112,7 +112,7 @@ roster_merge_result::has_content_conflic bool roster_merge_result::has_content_conflicts() const { - return file_content_conflicts.size() > 0; + return !file_content_conflicts.empty(); } bool ============================================================ --- schema_migration.cc e12c30bd63024372cfa3ac533a2261272374b180 +++ schema_migration.cc 3949185f804a860857b4e59056e5f46c3c2ab349 @@ -325,7 +325,7 @@ sqlite3_unhex_fn(sqlite3_context *f, int } // This is only ever used with 20-byte SHA1 hashes or empty strings, so // make sure that's what we've got. - if (decoded.size() != constants::idlen_bytes && decoded.size() != 0) + if (decoded.size() != constants::idlen_bytes && !decoded.empty()) { sqlite3_result_error(f, "unhex() result is the wrong length", -1); return; @@ -843,7 +843,7 @@ calculate_schema_id(sqlite3 * db, string tokenizer tokens(table_schema, sep); for (tokenizer::iterator i = tokens.begin(); i != tokens.end(); i++) { - if (schema.size() != 0) + if (!schema.empty()) schema += " "; schema += *i; } ============================================================ --- selectors.cc 0ad775938f68b07b748a6a5b671dbbd464d23c38 +++ selectors.cc 0992aac2e54e83d7fefbbf43d0d77c3f5ee40089 @@ -381,7 +381,7 @@ complete(options const & opts, lua_hooks P(F("expanding selection '%s'") % str); complete_selector(project, sels, completions); - N(completions.size() != 0, + N(!completions.empty(), F("no match for selection '%s'") % str); for (set::const_iterator i = completions.begin(); @@ -406,7 +406,7 @@ complete(options const & opts, lua_hooks complete(opts, lua, project, str, completions); - I(completions.size() > 0); + I(!completions.empty()); diagnose_ambiguous_expansion(project, str, completions); completion = *completions.begin(); ============================================================ --- simplestring_xform.cc dcaa75eb0ed67ddc119ef62f06c21bd7d13bf5cb +++ simplestring_xform.cc 0ce9a86370da9e0043729c1bae322655035694be @@ -299,7 +299,7 @@ UNIT_TEST(simplestring_xform, split_into vector< utf8 > words; words = split_into_words(utf8("")); - UNIT_TEST_CHECK(words.size() == 0); + UNIT_TEST_CHECK(words.empty()); words = split_into_words(utf8("foo")); UNIT_TEST_CHECK(words.size() == 1); ============================================================ --- string_queue.cc 34880af1af20cae04a527f370db60dd94ac6e97f +++ string_queue.cc 39f987fc625eb0f43ba86c794b40ad008fc5114e @@ -64,7 +64,7 @@ UNIT_TEST(string_queue, string_queue) UNIT_TEST_CHECK_THROW( sq1.pop_front( 1 ), logic_error ); // it's empty again - UNIT_TEST_CHECK( sq1.size() == 0 ); + UNIT_TEST_CHECK( sq1.empty() ); } #endif // BUILD_UNIT_TESTS ============================================================ --- tester.cc 144b85b2298949c9bbc303644bf972c36fd80c26 +++ tester.cc 7d7860782ceb19fec915b63ab6d7b3bebf829502 @@ -865,7 +865,7 @@ parse_makeflags(char const * mflags, vector mf(split_into_words(mflags)); - if (mf.size() == 0 || (mf.size() == 1 && mf[0] == "")) + if (mf.empty() || (mf.size() == 1 && mf[0] == "")) return; if (mf[0][0] != '-') @@ -987,7 +987,7 @@ parse_command_line(int argc, char const && tests_to_run.size() == 3 && jobs == 0), F("incorrect self-invocation; -r ")); - if (tests_to_run.size() == 0) + if (tests_to_run.empty()) { P(F("%s: no test suite specified\n") % argv[0]); need_help = true; ============================================================ --- ui.cc 31589a9e86d23d92cb4f87b310c6eb920d026db6 +++ ui.cc 8c499aa720bdce5eeb46deecea1cb94e0c8a2e3b @@ -461,7 +461,7 @@ user_interface::finish_ticking() user_interface::finish_ticking() { I(imp); - if (imp->tickers.size() == 0 && imp->last_write_was_a_tick) + if (imp->tickers.empty() && imp->last_write_was_a_tick) { imp->tick_trailer = ""; imp->t_writer->clear_line(); ============================================================ --- vocab.cc 321f9118a2194a0a8b3314af70836e4ac760039f +++ vocab.cc 164af638b42b1255dd2cffa88b56803c98a004fe @@ -96,7 +96,7 @@ verify(netsync_session_key & val) inline void verify(netsync_session_key & val) { - if (val().size() == 0) + if (val().empty()) { val.s = std::string(constants::netsync_session_key_length_in_bytes, 0); return; @@ -109,7 +109,7 @@ verify(netsync_hmac_value & val) inline void verify(netsync_hmac_value & val) { - if (val().size() == 0) + if (val().empty()) { val.s = std::string(constants::netsync_hmac_value_length_in_bytes, 0); return; ============================================================ --- work.cc 0ef66673796d2a408587d70530944a5a8747d488 +++ work.cc 39fcc1fec0b072c6ec588d59586b91b42b8e824c @@ -283,7 +283,7 @@ workspace::get_current_roster_shape(data // make_roster_for_revision does not handle correctly. if (rev.edges.size() == 1 && null_id(edge_old_revision(rev.edges.begin()))) { - I(ros.all_nodes().size() == 0); + I(ros.all_nodes().empty()); editable_roster_base er(ros, nis); edge_changes(rev.edges.begin()).apply_to(er); } @@ -672,7 +672,7 @@ workspace::init_attributes(file_path con { map attrs; lua.hook_init_attributes(path, attrs); - if (attrs.size() > 0) + if (!attrs.empty()) for (map::const_iterator i = attrs.begin(); i != attrs.end(); ++i) er.set_attr(path, attr_key(i->first), attr_value(i->second)); ============================================================ --- xdelta.cc a5a5ce3a1ed7c9dead79c526e382237697d54c04 +++ xdelta.cc 3e042fc714973dc387d2dbb3c3848e67b49488f0 @@ -156,7 +156,7 @@ find_match(match_table const & matches, && !delta.back().payload.empty()) { I(a[apos - 1] == *(delta.back().payload.rbegin())); - I(delta.back().payload.size() > 0); + I(!delta.back().payload.empty()); delta.back().payload.resize(delta.back().payload.size() - 1); --apos; --bpos; @@ -322,16 +322,16 @@ compute_delta(string const & a, // xdelta. several places of the xdelta code prefer assertions which are // only true with non-empty chunks anyways. - if (a.size() == 0 && b.size() != 0) + if (a.empty() && !b.empty()) delta_insns.push_back(insn(b)); - else if (a.size() != 0 && b.size() == 0) + else if (!a.empty() && b.empty()) delta_insns.push_back(insn(0, 0)); else if (a == b) delta_insns.push_back(insn(0, a.size())); else { - I(a.size() > 0); - I(b.size() > 0); + I(!a.empty()); + I(!b.empty()); L(FL("computing binary delta instructions")); compute_delta_insns(a, b, delta_insns);