<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Hi Markus<br><br></div><div>Thanks for your valuable feedback !<br><br>1.<br></div><div>"""<br>A simple high level design could be to use a 
std::vector<ScColumn*> and only allocate columns that really 
contain content or formatting. Additionally we'd need to introduce a way
 to store the format of a row. These row formats might not be visible to
 the user and would be just an internal way to handle the formatting for
 all not yet allocated columns.<br>"""<br><br>Let me make sure I get this idea right - <br><br>The aCol member in ScTable is declared as : <br></div><div><b>std::vector<ScColumn*> aCol;</b>  // Or can have wrapper on it own<br></div><div>and in the ScTable ctor aCol is init with a minimum number (or possibly 16K) of NULL pointer elements ie no ScColumn instance is allocated yet.<br></div><div>If we allocate space for all pointers in aCol vector then I think it might take around 128 KB just for pointers, <br>(point 1.A) so might want to allocate that too just when it is needed, hence avoid the need to keep a int var for keeping the index of last non null element.<br></div><div><br></div><div>While loading a sheet or user types in something in ith column for the first time, allocate ScColumn <br></div><div><b>if ( ! aCol[i] )<br>{<br></b></div><div><b>  aCol[i] = new ScColumn;<br></b></div><div><b>  // Apply any full row formattings to aCol[i]<br></b></div><div><b>}<br></b><br>2.<br></div><div>Correct me if I am wrong - I guess the formatting of each cell in a column is stored in pAttrArray member of ScColumn. So for storing full row formatting, we need<br></div><div>a data structure that map from row number to the formatting info. Definitely need your inputs and code pointers on this.<br><br><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class=""><div></div></span><div>This is surely not what we had in mind. Basically you just wrote a wrapper around std::vector.<br><br></div><div>There are a number of items a new design need:<br><br></div><div>* decision whether to store all ScColumn instances or only filled ones<br></div></div></div></div></blockquote><div> </div><div>3.  <br></div><div>If we use just std::vector<ScColumn>, we have to allocate n ScColumns if there are totally n columns in the sheet including blank ones upto the last non-blank column.<br></div><div>If we use std::vector<ScColumn*> we need to allocate ScColumn's for only the non blank columns in the document - definitely better.<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>* a way to handle the increased memory load<br></div><div>** most likely limiting the number of initial columns<br></div></div></div></div></blockquote><div> </div><div>See point 1. <br></div><div><br>4. <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><div>* a way to handle the performance impact of many columns<br></div><div>** most likely improving the iterations through all columns<br></div></div></div></div></blockquote><div><br></div><div>If we use std::vector<ScColumn>, We can trim the for loops to run from 0 up to current length of aCol.<br></div><div>If we use std::vector<ScColumn*>, We can trim the for loops to run from 0 up to current length of aCol and also skip running the inner logic whenever<br></div><div>aCol[i] == NULL, there by saving time, but not sure we can convert all column for loops like that offhand.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>* a better way to handle row formattings<br></div><div>** what happens if someone marks a whole row and formats it<br></div><div>** how to handle formatting for columns that were allocated after the user formatted the whole row<br><br></div></div></div></div></blockquote><div>See point 2. <br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><div>* most likely a way to store the last formatted column and the last column with content<br></div><div>** needs some inspecting which loops through the columns need which of the information<br><br></div></div></div></div></blockquote><div>See point 1.A, using this we can save time wasted on iterating over blank columns(aCol[i] == NULL).<br></div><div>Could you please explain why we need to remember "last formatted column" ?<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>Most likely a few more that I have not in mind right now.<br></div></div></div></div></blockquote><div> </div><div>Will surely wait for others to comment before proceeding any further.<br><br><br></div><div>Thanks,<br></div><div>Dennis<br><br></div><div><a href="http://www.ldcs.co.in">www.ldcs.co.in</a><br></div><div><br><br></div></div></div></div>