While looking at how to eliminate the feval in regexprep, I felt it was
easier to in fact implement the linked list manner of building the
matches in regexp at the same time, and as you suspected it is much
much
faster than resizing the return values at each new match. The time
comparison on my machine is
octave:1> s = repmat('s',[1,5]); regexp(s,'s')
ans =
1 2 3 4 5
octave:2> s = repmat('s',[1,1000]); tic; regexp(s,'s'); toc
Elapsed time is 0.798393 seconds.
octave:3> s = repmat('s',[1,2000]); tic; regexp(s,'s'); toc
Elapsed time is 3.107239 seconds.
octave:4> s = repmat('s',[1,3000]); tic; regexp(s,'s'); toc
Elapsed time is 7.145126 seconds.
prior to converting to using a linked list and with the attached
version is
octave:1> s = repmat('s',[1,5]); regexp(s,'s')
ans =
1 2 3 4 5
octave:2> s = repmat('s',[1,1000]); tic; regexp(s,'s'); toc
Elapsed time is 0.014191 seconds.
octave:3> s = repmat('s',[1,2000]); tic; regexp(s,'s'); toc
Elapsed time is 0.023567 seconds.
octave:4> s = repmat('s',[1,3000]); tic; regexp(s,'s'); toc
Elapsed time is 0.050476 seconds.
So it is linear time and not quadratic. What effect does this version
have on your xml4mat code? In any case I'm inclined to commit this
version as is, unless you see any other changes that you want to make
first. John comments?