StackOverflowMATLABchat / mlapp2classdef

Convert MATLAB App's XML file to *.m class definition
4 stars 5 forks source link

No Cell Array Preallocation #2

Closed sco1 closed 8 years ago

sco1 commented 8 years ago

The current XML parsing does not intelligently preallocate the cell array to the size of the data:

A = {};
ii = 1;
while ~feof(fID)
    A{ii} = fgetl(fID);
    ii = ii + 1;
end
fclose(fID);

This approach, while functional, is not particularly memory efficient and can potentially be a significant bottleneck depending on the size of the XML file being parsed. A more intelligent routine should be used to determine the length of the file and preallocate the cell array accordingly so it is not growing in memory.