Mercurial > octave
changeset 23829:01899bdd2a3a
Eliminate unnecessary std::string ("...") constructor calls when "..." suffices.
* Backend.cc, KeyMap.cc, QtHandlesUtils.cc, error.cc, help.cc, oct-hist.cc,
pr-output.cc, urlwrite.cc, utils.cc, variables.cc, __voronoi__.cc,
ov-classdef.cc, ov-fcn-handle.cc, pt-funcall.cc, pt-pr-code.cc, pt-tm-const.cc,
DASPK.cc, DASRT.cc, DASSL.cc, LSODE.cc, oct-env.cc, kpse.cc:
Eliminate unnecessary std::string ("...") constructor calls when "..."
suffices.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 04 Aug 2017 09:37:04 -0700 |
parents | 9ceb1916eadf |
children | 595d6716e3e2 |
files | libgui/graphics/Backend.cc libgui/graphics/KeyMap.cc libgui/graphics/QtHandlesUtils.cc libinterp/corefcn/error.cc libinterp/corefcn/help.cc libinterp/corefcn/oct-hist.cc libinterp/corefcn/pr-output.cc libinterp/corefcn/urlwrite.cc libinterp/corefcn/utils.cc libinterp/corefcn/variables.cc libinterp/dldfcn/__voronoi__.cc libinterp/octave-value/ov-classdef.cc libinterp/octave-value/ov-fcn-handle.cc libinterp/parse-tree/pt-funcall.cc libinterp/parse-tree/pt-pr-code.cc libinterp/parse-tree/pt-tm-const.cc liboctave/numeric/DASPK.cc liboctave/numeric/DASRT.cc liboctave/numeric/DASSL.cc liboctave/numeric/LSODE.cc liboctave/system/oct-env.cc liboctave/util/kpse.cc |
diffstat | 22 files changed, 88 insertions(+), 102 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/graphics/Backend.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/libgui/graphics/Backend.cc Fri Aug 04 09:37:04 2017 -0700 @@ -52,7 +52,7 @@ toolkitObjectProperty (const graphics_object& go) { if (go.isa ("figure")) - return std::string ("__plot_stream__"); + return "__plot_stream__"; else if (go.isa ("uicontrol") || go.isa ("uipanel") || go.isa ("uibuttongroup") @@ -61,7 +61,7 @@ || go.isa ("uitoolbar") || go.isa ("uipushtool") || go.isa ("uitoggletool")) - return std::string ("__object__"); + return "__object__"; else qCritical ("QtHandles::Backend: no __object__ property known for object " "of type %s", go.type ().c_str ());
--- a/libgui/graphics/KeyMap.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/libgui/graphics/KeyMap.cc Fri Aug 04 09:37:04 2017 -0700 @@ -250,7 +250,7 @@ keyMapper[Qt::Key_ydiaeresis] = "ydiaeresis"; } - return keyMapper.value (key, std::string ("<unknown key>")); + return keyMapper.value (key, "<unknown key>"); } }
--- a/libgui/graphics/QtHandlesUtils.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/libgui/graphics/QtHandlesUtils.cc Fri Aug 04 09:37:04 2017 -0700 @@ -112,14 +112,14 @@ if (! mapsInitialized) { - weightMap[std::string ("normal")] = QFont::Normal; - weightMap[std::string ("light")] = QFont::Light; - weightMap[std::string ("demi")] = QFont::DemiBold; - weightMap[std::string ("bold")] = QFont::Bold; + weightMap["normal"] = QFont::Normal; + weightMap["light"] = QFont::Light; + weightMap["demi"] = QFont::DemiBold; + weightMap["bold"] = QFont::Bold; - angleMap[std::string ("normal")] = QFont::StyleNormal; - angleMap[std::string ("italic")] = QFont::StyleItalic; - angleMap[std::string ("oblique")] = QFont::StyleOblique; + angleMap["normal"] = QFont::StyleNormal; + angleMap["italic"] = QFont::StyleItalic; + angleMap["oblique"] = QFont::StyleOblique; mapsInitialized = true; } @@ -170,7 +170,7 @@ figureSelectionType (QMouseEvent *event, bool isDoubleClick) { if (isDoubleClick) - return std::string ("open"); + return "open"; else { Qt::MouseButtons buttons = event->buttons (); @@ -179,27 +179,27 @@ if (mods == Qt::NoModifier) { if (buttons == Qt::LeftButton) - return std::string ("normal"); + return "normal"; else if (buttons == Qt::RightButton) - return std::string ("alt"); + return "alt"; #if defined (Q_WS_WIN) else if (buttons == (Qt::LeftButton | Qt::RightButton)) - return std::string ("extend"); + return "extend"; #elif defined (Q_WS_X11) else if (buttons == Qt::MidButton) - return std::string ("extend"); + return "extend"; #endif } else if (buttons == Qt::LeftButton) { if (mods == Qt::ShiftModifier) - return std::string ("extend"); + return "extend"; else if (mods == Qt::ControlModifier) - return std::string ("alt"); + return "alt"; } } - return std::string ("normal"); + return "normal"; } /*
--- a/libinterp/corefcn/error.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/libinterp/corefcn/error.cc Fri Aug 04 09:37:04 2017 -0700 @@ -209,7 +209,7 @@ } } - msg_string += base_msg + "\n"; + msg_string += base_msg + '\n'; if (save_last_error) { @@ -411,7 +411,7 @@ if (name) msg_string = std::string (name) + ": "; - msg_string += base_msg + "\n"; + msg_string += base_msg + '\n'; Vlast_warning_id = id; Vlast_warning_message = base_msg;
--- a/libinterp/corefcn/help.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/libinterp/corefcn/help.cc Fri Aug 04 09:37:04 2017 -0700 @@ -286,8 +286,7 @@ } } else - type = val.is_user_script () - ? std::string ("script") : std::string ("function"); + type = val.is_user_script () ? "script" : "function"; } } else
--- a/libinterp/corefcn/oct-hist.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/libinterp/corefcn/oct-hist.cc Fri Aug 04 09:37:04 2017 -0700 @@ -108,7 +108,7 @@ default_history_timestamp_format (void) { return - std::string ("# Octave " OCTAVE_VERSION ", %a %b %d %H:%M:%S %Y %Z <") + "# Octave " OCTAVE_VERSION ", %a %b %d %H:%M:%S %Y %Z <" + octave::sys::env::get_user_name () + '@' + octave::sys::env::get_host_name ()
--- a/libinterp/corefcn/pr-output.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/libinterp/corefcn/pr-output.cc Fri Aug 04 09:37:04 2017 -0700 @@ -3926,7 +3926,7 @@ { init_format_state (); set_output_prec_and_fw (5, 10); - format = std::string ("short"); + format = "short"; } format_string = format;
--- a/libinterp/corefcn/urlwrite.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/libinterp/corefcn/urlwrite.cc Fri Aug 04 09:37:04 2017 -0700 @@ -287,7 +287,7 @@ std::string user = (nargin > 1) ? args(1).xstring_value ("__ftp__: USER must be a string") - : std::string ("anonymous"); + : "anonymous"; std::string passwd = (nargin > 2) ? args(2).xstring_value ("__ftp__: PASSWD must be a string")
--- a/libinterp/corefcn/utils.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/libinterp/corefcn/utils.cc Fri Aug 04 09:37:04 2017 -0700 @@ -520,13 +520,12 @@ { std::string retval; - if (dir.length () > 0) + if (! dir.empty ()) { octave::load_path& lp = octave::__get_load_path__ ("contents_in_file_path"); std::string tcontents - = octave::sys::file_ops::concat (lp.find_dir (dir), - std::string ("Contents.m")); + = octave::sys::file_ops::concat (lp.find_dir (dir), "Contents.m"); octave::sys::file_stat fs (tcontents); @@ -835,7 +834,7 @@ default: { - static char retval[2] = "\0"; + static char retval[2] {'\0', '\0'}; retval[0] = c; return retval;
--- a/libinterp/corefcn/variables.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/libinterp/corefcn/variables.cc Fri Aug 04 09:37:04 2017 -0700 @@ -1651,8 +1651,7 @@ octave::feval ("load", octave_value (nm), 0); - std::string newmsg = std::string ("Variables in the file ") - + nm + ":\n\n"; + std::string newmsg = "Variables in the file " + nm + ":\n\n"; retval = do_who (interp, i, argv, return_list, verbose, newmsg);
--- a/libinterp/dldfcn/__voronoi__.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/libinterp/dldfcn/__voronoi__.cc Fri Aug 04 09:37:04 2017 -0700 @@ -343,7 +343,7 @@ std::string caller = (args.length () > 0 ? args(0).xstring_value ("__voronoi__: CALLER must be a string") - : std::string ("__voronoi__")); + : "__voronoi__"); err_disabled_feature (caller, "Qhull");
--- a/libinterp/octave-value/ov-classdef.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/libinterp/octave-value/ov-classdef.cc Fri Aug 04 09:37:04 2017 -0700 @@ -2522,7 +2522,7 @@ else if (t->expression ()) return t->expression ()->original_text (); else - return std::string ("true"); + return "true"; } cdef_class
--- a/libinterp/octave-value/ov-fcn-handle.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/libinterp/octave-value/ov-fcn-handle.cc Fri Aug 04 09:37:04 2017 -0700 @@ -691,10 +691,10 @@ std::string octaveroot; std::string fpath; - if (nm.find_first_of ("\n") != std::string::npos) + if (nm.find_first_of ('\n') != std::string::npos) { - size_t pos1 = nm.find_first_of ("\n"); - size_t pos2 = nm.find_first_of ("\n", pos1 + 1); + size_t pos1 = nm.find_first_of ('\n'); + size_t pos2 = nm.find_first_of ('\n', pos1 + 1); octaveroot = nm.substr (pos1 + 1, pos2 - pos1 - 1); fpath = nm.substr (pos2 + 1); nm = nm.substr (0, pos1);
--- a/libinterp/parse-tree/pt-funcall.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/libinterp/parse-tree/pt-funcall.cc Fri Aug 04 09:37:04 2017 -0700 @@ -50,7 +50,7 @@ else { octave_function *fp = fcn.function_value (); - std::string nm = (fp ? fp->name () : std::string ("<invalid-function>")); + std::string nm = (fp ? fp->name () : "<invalid-function>"); os << nm << " (";
--- a/libinterp/parse-tree/pt-pr-code.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/libinterp/parse-tree/pt-pr-code.cc Fri Aug 04 09:37:04 2017 -0700 @@ -375,7 +375,7 @@ std::string fcn_name = fcn.name (); - os << (fcn_name.empty () ? std::string ("(empty)") : fcn_name) << ' '; + os << (fcn_name.empty () ? "(empty)" : fcn_name) << ' '; tree_parameter_list *param_list = fcn.parameter_list (); @@ -444,7 +444,7 @@ print_parens (id, "("); std::string nm = id.name (); - os << (nm.empty () ? std::string ("(empty)") : nm); + os << (nm.empty () ? "(empty)" : nm); print_parens (id, ")"); }
--- a/libinterp/parse-tree/pt-tm-const.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/libinterp/parse-tree/pt-tm-const.cc Fri Aug 04 09:37:04 2017 -0700 @@ -63,8 +63,8 @@ tm_row_const::tm_row_const_rep::do_init_element (const octave_value& val, bool& first_elem) { - std::string this_elt_class_nm - = val.isobject () ? std::string ("class") : val.class_name (); + std::string this_elt_class_nm = val.isobject () ? "class" + : val.class_name (); class_nm = get_concat_class (class_nm, this_elt_class_nm);
--- a/liboctave/numeric/DASPK.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/liboctave/numeric/DASPK.cc Fri Aug 04 09:37:04 2017 -0700 @@ -723,8 +723,7 @@ break; case -1: - retval = std::string ("a large amount of work has been expended (t =") - + t_curr + ')'; + retval = "a large amount of work has been expended (t =" + t_curr + ')'; break; case -2: @@ -732,39 +731,37 @@ break; case -3: - retval = std::string ("error weight became zero during problem. (t = ") - + t_curr - + "; solution component i vanished, and atol or atol(i) == 0)"; + retval = "error weight became zero during problem. (t = " + t_curr + + "; solution component i vanished, and atol or atol(i) == 0)"; break; case -6: - retval = std::string ("repeated error test failures on the last attempted step (t = ") + retval = "repeated error test failures on the last attempted step (t = " + t_curr + ')'; break; case -7: - retval = std::string ("the corrector could not converge (t = ") - + t_curr + ')'; + retval = "the corrector could not converge (t = " + t_curr + ')'; break; case -8: - retval = std::string ("the matrix of partial derivatives is singular (t = ") - + t_curr + ')'; + retval = "the matrix of partial derivatives is singular (t = " + t_curr + + ')'; break; case -9: - retval = std::string ("the corrector could not converge (t = ") - + t_curr + "; repeated test failures)"; + retval = "the corrector could not converge (t = " + t_curr + + "; repeated test failures)"; break; case -10: - retval = std::string ("corrector could not converge because IRES was -1 (t = ") + retval = "corrector could not converge because IRES was -1 (t = " + t_curr + ')'; break; case -11: - retval = std::string ("return requested in user-supplied function (t = ") - + t_curr + ')'; + retval = "return requested in user-supplied function (t = " + t_curr + + ')'; break; case -12: @@ -772,12 +769,12 @@ break; case -13: - retval = std::string ("unrecoverable error encountered inside user's PSOL function (t = ") + retval = "unrecoverable error encountered inside user's PSOL function (t = " + t_curr + ')'; break; case -14: - retval = std::string ("the Krylov linear system solver failed to converge (t = ") + retval = "the Krylov linear system solver failed to converge (t = " + t_curr + ')'; break;
--- a/liboctave/numeric/DASRT.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/liboctave/numeric/DASRT.cc Fri Aug 04 09:37:04 2017 -0700 @@ -586,8 +586,7 @@ break; case -1: - retval = std::string ("a large amount of work has been expended (t =") - + t_curr + ')'; + retval = "a large amount of work has been expended (t =" + t_curr + ')'; break; case -2: @@ -595,39 +594,37 @@ break; case -3: - retval = std::string ("error weight became zero during problem. (t = ") - + t_curr - + "; solution component i vanished, and atol or atol(i) == 0)"; + retval = "error weight became zero during problem. (t = " + t_curr + + "; solution component i vanished, and atol or atol(i) == 0)"; break; case -6: - retval = std::string ("repeated error test failures on the last attempted step (t = ") + retval = "repeated error test failures on the last attempted step (t = " + t_curr + ')'; break; case -7: - retval = std::string ("the corrector could not converge (t = ") - + t_curr + ')'; + retval = "the corrector could not converge (t = " + t_curr + ')'; break; case -8: - retval = std::string ("the matrix of partial derivatives is singular (t = ") - + t_curr + ')'; + retval = "the matrix of partial derivatives is singular (t = " + t_curr + + ')'; break; case -9: - retval = std::string ("the corrector could not converge (t = ") - + t_curr + "; repeated test failures)"; + retval = "the corrector could not converge (t = " + t_curr + + "; repeated test failures)"; break; case -10: - retval = std::string ("corrector could not converge because IRES was -1 (t = ") + retval = "corrector could not converge because IRES was -1 (t = " + t_curr + ')'; break; case -11: - retval = std::string ("return requested in user-supplied function (t = ") - + t_curr + ')'; + retval = "return requested in user-supplied function (t = " + t_curr + + ')'; break; case -12:
--- a/liboctave/numeric/DASSL.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/liboctave/numeric/DASSL.cc Fri Aug 04 09:37:04 2017 -0700 @@ -524,8 +524,7 @@ break; case -1: - retval = std::string ("a large amount of work has been expended (t =") - + t_curr + ')'; + retval = "a large amount of work has been expended (t =" + t_curr + ')'; break; case -2: @@ -533,39 +532,37 @@ break; case -3: - retval = std::string ("error weight became zero during problem. (t = ") - + t_curr - + "; solution component i vanished, and atol or atol(i) == 0)"; + retval = "error weight became zero during problem. (t = " + t_curr + + "; solution component i vanished, and atol or atol(i) == 0)"; break; case -6: - retval = std::string ("repeated error test failures on the last attempted step (t = ") + retval = "repeated error test failures on the last attempted step (t = " + t_curr + ')'; break; case -7: - retval = std::string ("the corrector could not converge (t = ") - + t_curr + ')'; + retval = "the corrector could not converge (t = " + t_curr + ')'; break; case -8: - retval = std::string ("the matrix of partial derivatives is singular (t = ") - + t_curr + ')'; + retval = "the matrix of partial derivatives is singular (t = " + t_curr + + ')'; break; case -9: - retval = std::string ("the corrector could not converge (t = ") - + t_curr + "; repeated test failures)"; + retval = "the corrector could not converge (t = " + t_curr + + "; repeated test failures)"; break; case -10: - retval = std::string ("corrector could not converge because IRES was -1 (t = ") + retval = "corrector could not converge because IRES was -1 (t = " + t_curr + ')'; break; case -11: - retval = std::string ("return requested in user-supplied function (t = ") - + t_curr + ')'; + retval = "return requested in user-supplied function (t = " + t_curr + + ')'; break; case -12:
--- a/liboctave/numeric/LSODE.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/liboctave/numeric/LSODE.cc Fri Aug 04 09:37:04 2017 -0700 @@ -333,8 +333,8 @@ break; case -1: - retval = std::string ("excess work on this call (t = ") - + t_curr + "; perhaps wrong integration method)"; + retval = "excess work on this call (t = " + t_curr + + "; perhaps wrong integration method)"; break; case -2: @@ -346,20 +346,18 @@ break; case -4: - retval = std::string ("repeated error test failures (t = ") - + t_curr + "; check all inputs)"; + retval = "repeated error test failures (t = " + t_curr + + "; check all inputs)"; break; case -5: - retval = std::string ("repeated convergence failures (t = ") - + t_curr - + "; perhaps bad Jacobian supplied or wrong choice of integration method or tolerances)"; + retval = "repeated convergence failures (t = " + t_curr + + "; perhaps bad Jacobian supplied or wrong choice of integration method or tolerances)"; break; case -6: - retval = std::string ("error weight became zero during problem. (t = ") - + t_curr - + "; solution component i vanished, and atol or atol(i) == 0)"; + retval = "error weight became zero during problem. (t = " + t_curr + + "; solution component i vanished, and atol or atol(i) == 0)"; break; case -13:
--- a/liboctave/system/oct-env.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/liboctave/system/oct-env.cc Fri Aug 04 09:37:04 2017 -0700 @@ -507,7 +507,7 @@ sys::password pw = sys::password::getpwuid ( sys::getuid ()); - user_name = (pw ? pw.name () : std::string ("unknown")); + user_name = (pw ? pw.name () : "unknown"); } return user_name; @@ -536,8 +536,8 @@ return value ? value : ""; } - // Do the work of changing to the directory NEWDIR. Handle symbolic - // link following, etc. + // Do the work of changing to the directory NEWDIR. + // Handle symbolic link following, etc. bool env::do_chdir (const std::string& newdir)
--- a/liboctave/util/kpse.cc Thu Aug 03 08:43:49 2017 -0700 +++ b/liboctave/util/kpse.cc Fri Aug 04 09:37:04 2017 -0700 @@ -714,7 +714,7 @@ octave::sys::password p = octave::sys::password::getpwnam (user); /* If no such user, just use '.'. */ - std::string home = (p ? p.dir () : std::string (".")); + std::string home = (p ? p.dir () : "."); if (home.empty ()) home = ".";