<div dir="ltr">Hey Dennis,<br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 10, 2015 at 3:30 PM, Dennis Francis <span dir="ltr"><<a href="mailto:dennisfrancis.in@gmail.com" target="_blank">dennisfrancis.in@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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><span class="">"""<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></span>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></div></div></blockquote><div><br></div><div>Please don't allocate any pointers in advance. There is no value in that and it just causes higher memory load.<br><br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></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></div></div></div></div></blockquote><div><br></div><div>As we would not pre allocate the vector it would be more like:<br><br></div><div>if (i >= aCol.size())<br>{<br></div><div>    aCol.resize(i+1);<br>}<br></div><div>if (!aCol[i])<br>{<br></div><div>   aCol[i] = new ScColumn;<br></div><div>} <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><b></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></div></div></div></div></blockquote><div><br><br></div><div>Either that, which would be quite trivial or a way to have a concept where row and document formats are handled independently from the column formatting. E.g instead of our current design that stores a formatting entry even for a column that has default formatting only store entries for columns and cells that have been explicitly formatted. So if there is no column/cell formatting (they are basically the same) we would take the row formatting and if no row formatting is around take the document formatting.<br><br></div><div>Which of the two makes more sense would need some more design work.<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br><br></div><span class=""><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><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></span><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></div></div></div></div></blockquote><div><br></div><div>The question is how likely it is to find such a case where it matters. The bigger problem would be that for std::vector<ScColumn> ScColumn needs to be either movable or copyable. Both are most likely things we are not prepared to do.<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><span class=""><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></span><div>See point 1. <br></div></div></div></div></blockquote><div><br></div><div>As mentioned there we should only allocate entries that are necessary. So an empty document basically just needs the size of an empty std::vector. Also ideas like the row formatting are part of the solution to this problem.<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><div><br>4. <br></div><span class=""><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></span><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></div></blockquote><div><br></div><div>You need to skip vector entries that are NULL anyway.<br><br></div><div>Obviously you need to convert all loops as you have some problems otherwise.<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><span class=""><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></span><div>See point 2. <br></div><span class=""><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></span><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></div></div></blockquote><div><br></div><div>Depending on the design this happens directly or you need to do it indirectly. These comments where general comments without looking at any implementation. In the implementation with the std::vector<ScColumn*> this happens indirectly though std::vector<ScColumn*>size().<br><br></div><div> The idea to store the last column with content might help us avoid looping through a lot of columns that are only formatted. It is not yet sure if that is really necessary.<br><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><span class=""><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></span><div>Will surely wait for others to comment before proceeding any further.<br></div></div></div></div></blockquote><div><br><br></div><div>The proposed design is based on a discussion between Kohei and met. Maybe Eike has some additional comments otherwise feel free to work on a design.<br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br><br></div><div>Thanks,<br></div><div>Dennis<br><br></div><div><a href="http://www.ldcs.co.in" target="_blank">www.ldcs.co.in</a><br></div><div><br><br></div></div></div></div>
</blockquote></div><br></div></div>