octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there an easy way to speed cellstr()?


From: Daniel J Sebald
Subject: Re: Is there an easy way to speed cellstr()?
Date: Sun, 29 Jul 2012 14:17:03 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111108 Fedora/3.1.16-1.fc14 Thunderbird/3.1.16

On 07/29/2012 01:14 PM, Daniel J Sebald wrote:

string_vector s = args(0).all_strings ();
retval = Cell (s, true);
int common_string_length = s(0).length ();
for (<indextype> i = 0; i < s.length(); i++)
{
retval(i).insert(s(i).c_str(), common_string_length);
}

Forgot the initializer here!  E.g.,

          string_vector s = args(0).all_strings ();
retval = Cell (s, s(0)); // Pass in first value as initial value for all strings, which are same length
          int common_string_length = s(0).length ();
          for (<indextype> i = 0; i < s.length(); i++)
             {
                // Just overwrite string contents, no memory reallocation
                retval(i).insert(s(i).c_str(), common_string_length);
             }

Dan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]