Mercurial > octave
comparison libinterp/corefcn/pr-output.cc @ 23807:336f89b6208b
Use character literals 'c' rather than string literals "c" when possible.
Better performance when string constructor isn't required.
* Figure.cc, __init_qt__.cc, files-dock-widget.cc, file-editor-tab.cc,
file-editor.cc, octave-qscintilla.cc, main-window.cc, octave-dock-widget.cc,
octave-qt-link.cc, parser.cc, webinfo.cc, resource-manager.cc,
settings-dialog.cc, workspace-view.cc, __magick_read__.cc, balance.cc,
debug.cc, dynamic-ld.cc, ft-text-renderer.cc, gl-render.cc, gl2ps-print.cc,
graphics.cc, hook-fcn.h, input.cc, load-path.cc, load-save.cc, ls-hdf5.cc,
oct-hist.cc, oct-stream.cc, pager.cc, pr-output.cc, qz.cc, symtab.cc, symtab.h,
tril.cc, __delaunayn__.cc, __init_fltk__.cc, __voronoi__.cc, audioread.cc,
ccolamd.cc, colamd.cc, convhulln.cc, ov-base-int.cc, ov-base-mat.cc,
ov-base-scalar.cc, ov-base.cc, ov-bool-mat.cc, ov-cell.cc, ov-class.cc,
ov-classdef.cc, ov-colon.cc, ov-complex.cc, ov-cx-mat.cc, ov-fcn-handle.cc,
ov-fcn-inline.cc, ov-fcn.h, ov-flt-cx-mat.cc, ov-flt-re-mat.cc, ov-java.cc,
ov-oncleanup.cc, ov-range.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-str-mat.cc,
ov-struct.cc, ov-usr-fcn.cc, ov.cc, octave.cc, bp-table.cc, jit-ir.cc,
jit-ir.h, jit-typeinfo.cc, pt-funcall.cc, pt-idx.cc, pt-pr-code.cc, pt.h,
Array.cc, CDiagMatrix.cc, CMatrix.cc, CNDArray.cc, CRowVector.cc, CSparse.cc,
Range.cc, boolSparse.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc,
dRowVector.cc, dSparse.cc, fCDiagMatrix.cc, fCMatrix.cc, fCNDArray.cc,
fCRowVector.cc, fDiagMatrix.cc, fMatrix.cc, fNDArray.cc, fRowVector.cc,
idx-vector.cc, intNDArray.cc, CollocWt.cc, DASPK.cc, DASRT.cc, DASSL.cc,
LSODE.cc, oct-time.cc, cmd-hist.cc, kpse.cc, lo-array-errwarn.cc, lo-regexp.cc,
lo-utils.cc, str-vec.cc, url-transfer.cc, main-cli.cc, main-gui.cc,
mkoctfile.in.cc:
Replace 1-character string literals "c" with the character literal 'c'.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 28 Jul 2017 15:40:00 -0700 |
parents | 90689bdbe048 |
children | 01899bdd2a3a |
comparison
equal
deleted
inserted
replaced
23806:6925c8d2cd87 | 23807:336f89b6208b |
---|---|
402 lastd = nextd; | 402 lastd = nextd; |
403 | 403 |
404 std::ostringstream buf; | 404 std::ostringstream buf; |
405 buf.flags (std::ios::fixed); | 405 buf.flags (std::ios::fixed); |
406 buf << std::setprecision (0) << static_cast<int>(n) | 406 buf << std::setprecision (0) << static_cast<int>(n) |
407 << "/" << static_cast<int>(d); | 407 << '/' << static_cast<int>(d); |
408 m++; | 408 m++; |
409 | 409 |
410 if (n < 0 && d < 0) | 410 if (n < 0 && d < 0) |
411 { | 411 { |
412 // Double negative, string can be two characters longer.. | 412 // Double negative, string can be two characters longer.. |
429 lastd = - lastd; | 429 lastd = - lastd; |
430 lastn = - lastn; | 430 lastn = - lastn; |
431 std::ostringstream buf; | 431 std::ostringstream buf; |
432 buf.flags (std::ios::fixed); | 432 buf.flags (std::ios::fixed); |
433 buf << std::setprecision (0) << static_cast<int>(lastn) | 433 buf << std::setprecision (0) << static_cast<int>(lastn) |
434 << "/" << static_cast<int>(lastd); | 434 << '/' << static_cast<int>(lastd); |
435 s = buf.str (); | 435 s = buf.str (); |
436 } | 436 } |
437 } | 437 } |
438 | 438 |
439 return s; | 439 return s; |
479 | 479 |
480 os.flags (static_cast<std::ios::fmtflags> | 480 os.flags (static_cast<std::ios::fmtflags> |
481 (prf.f.fmt | prf.f.up | prf.f.sp)); | 481 (prf.f.fmt | prf.f.up | prf.f.sp)); |
482 | 482 |
483 if (fw > 0 && s.length () > static_cast<unsigned int>(fw)) | 483 if (fw > 0 && s.length () > static_cast<unsigned int>(fw)) |
484 os << "*"; | 484 os << '*'; |
485 else | 485 else |
486 os << s; | 486 os << s; |
487 | 487 |
488 return os; | 488 return os; |
489 } | 489 } |
1586 else | 1586 else |
1587 os << " + "; | 1587 os << " + "; |
1588 | 1588 |
1589 pr_imag_float (os, i, i_fw); | 1589 pr_imag_float (os, i, i_fw); |
1590 } | 1590 } |
1591 os << "i"; | 1591 os << 'i'; |
1592 } | 1592 } |
1593 } | 1593 } |
1594 | 1594 |
1595 static void | 1595 static void |
1596 print_empty_matrix (std::ostream& os, octave_idx_type nr, octave_idx_type nc, | 1596 print_empty_matrix (std::ostream& os, octave_idx_type nr, octave_idx_type nc, |
1601 if (pr_as_read_syntax) | 1601 if (pr_as_read_syntax) |
1602 { | 1602 { |
1603 if (nr == 0 && nc == 0) | 1603 if (nr == 0 && nc == 0) |
1604 os << "[]"; | 1604 os << "[]"; |
1605 else | 1605 else |
1606 os << "zeros (" << nr << ", " << nc << ")"; | 1606 os << "zeros (" << nr << ", " << nc << ')'; |
1607 } | 1607 } |
1608 else | 1608 else |
1609 { | 1609 { |
1610 os << "[]"; | 1610 os << "[]"; |
1611 | 1611 |
1612 if (Vprint_empty_dimensions) | 1612 if (Vprint_empty_dimensions) |
1613 os << "(" << nr << "x" << nc << ")"; | 1613 os << '(' << nr << 'x' << nc << ')'; |
1614 } | 1614 } |
1615 } | 1615 } |
1616 | 1616 |
1617 static void | 1617 static void |
1618 print_empty_nd_array (std::ostream& os, const dim_vector& dims, | 1618 print_empty_nd_array (std::ostream& os, const dim_vector& dims, |
1619 bool pr_as_read_syntax) | 1619 bool pr_as_read_syntax) |
1620 { | 1620 { |
1621 assert (dims.any_zero ()); | 1621 assert (dims.any_zero ()); |
1622 | 1622 |
1623 if (pr_as_read_syntax) | 1623 if (pr_as_read_syntax) |
1624 os << "zeros (" << dims.str (',') << ")"; | 1624 os << "zeros (" << dims.str (',') << ')'; |
1625 else | 1625 else |
1626 { | 1626 { |
1627 os << "[]"; | 1627 os << "[]"; |
1628 | 1628 |
1629 if (Vprint_empty_dimensions) | 1629 if (Vprint_empty_dimensions) |
1630 os << "(" << dims.str () << ")"; | 1630 os << '(' << dims.str () << ')'; |
1631 } | 1631 } |
1632 } | 1632 } |
1633 | 1633 |
1634 static void | 1634 static void |
1635 pr_scale_header (std::ostream& os, double scale) | 1635 pr_scale_header (std::ostream& os, double scale) |
1764 os << "[\n"; | 1764 os << "[\n"; |
1765 | 1765 |
1766 os << m; | 1766 os << m; |
1767 | 1767 |
1768 if (pr_as_read_syntax) | 1768 if (pr_as_read_syntax) |
1769 os << "]"; | 1769 os << ']'; |
1770 | 1770 |
1771 return; | 1771 return; |
1772 } | 1772 } |
1773 | 1773 |
1774 octave_idx_type inc = nc; | 1774 octave_idx_type inc = nc; |
1900 os << "[\n"; | 1900 os << "[\n"; |
1901 | 1901 |
1902 os << Matrix (m); | 1902 os << Matrix (m); |
1903 | 1903 |
1904 if (pr_as_read_syntax) | 1904 if (pr_as_read_syntax) |
1905 os << "]"; | 1905 os << ']'; |
1906 | 1906 |
1907 return; | 1907 return; |
1908 } | 1908 } |
1909 | 1909 |
1910 octave_idx_type inc = nc; | 1910 octave_idx_type inc = nc; |
1946 if (col >= nc) | 1946 if (col >= nc) |
1947 os << " ]"; | 1947 os << " ]"; |
1948 else | 1948 else |
1949 os << " ...\n"; | 1949 os << " ...\n"; |
1950 } | 1950 } |
1951 os << ")"; | 1951 os << ')'; |
1952 } | 1952 } |
1953 else | 1953 else |
1954 { | 1954 { |
1955 octave::preserve_stream_state stream_state (os); | 1955 octave::preserve_stream_state stream_state (os); |
1956 | 1956 |
2040 for (int k = 2; k < ndims; k++) | 2040 for (int k = 2; k < ndims; k++) |
2041 { | 2041 { |
2042 buf << ra_idx(k) + 1; | 2042 buf << ra_idx(k) + 1; |
2043 | 2043 |
2044 if (k < ndims - 1) | 2044 if (k < ndims - 1) |
2045 buf << ","; | 2045 buf << ','; |
2046 else | 2046 else |
2047 buf << ")"; | 2047 buf << ')'; |
2048 } | 2048 } |
2049 | 2049 |
2050 nm += buf.str (); | 2050 nm += buf.str (); |
2051 } | 2051 } |
2052 | 2052 |
2103 double ip = c.imag (); | 2103 double ip = c.imag (); |
2104 | 2104 |
2105 if (rp == 0.0) | 2105 if (rp == 0.0) |
2106 { | 2106 { |
2107 if (ip == 0.0) | 2107 if (ip == 0.0) |
2108 os << " "; | 2108 os << ' '; |
2109 else | 2109 else |
2110 os << "i"; | 2110 os << 'i'; |
2111 } | 2111 } |
2112 else if (ip == 0.0) | 2112 else if (ip == 0.0) |
2113 pr_plus_format (os, rp); | 2113 pr_plus_format (os, rp); |
2114 else | 2114 else |
2115 os << "c"; | 2115 os << 'c'; |
2116 } | 2116 } |
2117 | 2117 |
2118 void | 2118 void |
2119 octave_print_internal (std::ostream& os, const Complex& c, | 2119 octave_print_internal (std::ostream& os, const Complex& c, |
2120 bool pr_as_read_syntax) | 2120 bool pr_as_read_syntax) |
2182 os << "[\n"; | 2182 os << "[\n"; |
2183 | 2183 |
2184 os << cm; | 2184 os << cm; |
2185 | 2185 |
2186 if (pr_as_read_syntax) | 2186 if (pr_as_read_syntax) |
2187 os << "]"; | 2187 os << ']'; |
2188 | 2188 |
2189 return; | 2189 return; |
2190 } | 2190 } |
2191 | 2191 |
2192 octave_idx_type inc = nc; | 2192 octave_idx_type inc = nc; |
2320 os << "[\n"; | 2320 os << "[\n"; |
2321 | 2321 |
2322 os << ComplexMatrix (cm); | 2322 os << ComplexMatrix (cm); |
2323 | 2323 |
2324 if (pr_as_read_syntax) | 2324 if (pr_as_read_syntax) |
2325 os << "]"; | 2325 os << ']'; |
2326 | 2326 |
2327 return; | 2327 return; |
2328 } | 2328 } |
2329 | 2329 |
2330 octave_idx_type inc = nc; | 2330 octave_idx_type inc = nc; |
2366 if (col >= nc) | 2366 if (col >= nc) |
2367 os << " ]"; | 2367 os << " ]"; |
2368 else | 2368 else |
2369 os << " ...\n"; | 2369 os << " ...\n"; |
2370 } | 2370 } |
2371 os << ")"; | 2371 os << ')'; |
2372 } | 2372 } |
2373 else | 2373 else |
2374 { | 2374 { |
2375 octave::preserve_stream_state stream_state (os); | 2375 octave::preserve_stream_state stream_state (os); |
2376 | 2376 |
2465 os << "[\n"; | 2465 os << "[\n"; |
2466 | 2466 |
2467 os << Matrix (m); | 2467 os << Matrix (m); |
2468 | 2468 |
2469 if (pr_as_read_syntax) | 2469 if (pr_as_read_syntax) |
2470 os << "]"; | 2470 os << ']'; |
2471 | 2471 |
2472 return; | 2472 return; |
2473 } | 2473 } |
2474 | 2474 |
2475 octave_idx_type inc = nc; | 2475 octave_idx_type inc = nc; |
2514 if (col >= nc) | 2514 if (col >= nc) |
2515 os << " ]"; | 2515 os << " ]"; |
2516 else | 2516 else |
2517 os << " ...\n"; | 2517 os << " ...\n"; |
2518 } | 2518 } |
2519 os << ")"; | 2519 os << ')'; |
2520 } | 2520 } |
2521 else | 2521 else |
2522 { | 2522 { |
2523 octave::preserve_stream_state stream_state (os); | 2523 octave::preserve_stream_state stream_state (os); |
2524 | 2524 |
2901 for (int k = 2; k < ndims; k++) | 2901 for (int k = 2; k < ndims; k++) |
2902 { | 2902 { |
2903 buf << ra_idx(k) + 1; | 2903 buf << ra_idx(k) + 1; |
2904 | 2904 |
2905 if (k < ndims - 1) | 2905 if (k < ndims - 1) |
2906 buf << ","; | 2906 buf << ','; |
2907 else | 2907 else |
2908 buf << ")"; | 2908 buf << ')'; |
2909 } | 2909 } |
2910 | 2910 |
2911 nm += buf.str (); | 2911 nm += buf.str (); |
2912 } | 2912 } |
2913 | 2913 |
3166 for (int k = 2; k < ndims; k++) | 3166 for (int k = 2; k < ndims; k++) |
3167 { | 3167 { |
3168 buf << ra_idx(k) + 1; | 3168 buf << ra_idx(k) + 1; |
3169 | 3169 |
3170 if (k < ndims - 1) | 3170 if (k < ndims - 1) |
3171 buf << ","; | 3171 buf << ','; |
3172 else | 3172 else |
3173 buf << ")"; | 3173 buf << ')'; |
3174 } | 3174 } |
3175 | 3175 |
3176 nm += buf.str (); | 3176 nm += buf.str (); |
3177 | 3177 |
3178 os << nm << " =\n"; | 3178 os << nm << " =\n"; |
3274 for (int k = 2; k < ndims; k++) | 3274 for (int k = 2; k < ndims; k++) |
3275 { | 3275 { |
3276 buf << ra_idx(k) + 1; | 3276 buf << ra_idx(k) + 1; |
3277 | 3277 |
3278 if (k < ndims - 1) | 3278 if (k < ndims - 1) |
3279 buf << ","; | 3279 buf << ','; |
3280 else | 3280 else |
3281 buf << ")"; | 3281 buf << ')'; |
3282 } | 3282 } |
3283 | 3283 |
3284 nm += buf.str (); | 3284 nm += buf.str (); |
3285 | 3285 |
3286 os << nm << " =\n"; | 3286 os << nm << " =\n"; |
3313 } | 3313 } |
3314 os << "\n"; | 3314 os << "\n"; |
3315 } | 3315 } |
3316 | 3316 |
3317 if (pr_as_read_syntax) | 3317 if (pr_as_read_syntax) |
3318 os << "]"; | 3318 os << ']'; |
3319 } | 3319 } |
3320 else | 3320 else |
3321 { | 3321 { |
3322 octave::preserve_stream_state stream_state (os); | 3322 octave::preserve_stream_state stream_state (os); |
3323 | 3323 |