changeset 23306:a009a871825c

Improve performance of dlmread by pre-allocating larger array (bug #50102). * dlmread.cc (Fdlmread): Increase rmax, max number of rows, in powers of 2 to avoid constant re-sizing of output matrix.
author Rik <rik@octave.org>
date Sun, 19 Mar 2017 13:27:30 -0700
parents 34c75889ed50
children 507e3150f034
files libinterp/corefcn/dlmread.cc
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/dlmread.cc	Sun Mar 19 08:26:39 2017 -0700
+++ b/libinterp/corefcn/dlmread.cc	Sun Mar 19 13:27:30 2017 -0700
@@ -405,7 +405,7 @@
             {
               // Use resize_and_fill for the case of unequal length rows.
               // Keep rmax a power of 2.
-              rmax = 2 * std::max (r-1, static_cast<octave_idx_type> (1));
+              rmax = std::max (2*(r-1), rmax);
               cmax = std::max (c, cmax);
               if (iscmplx)
                 cdata.resize (rmax, cmax, empty_value);