Yeah, the substring mistake in parsing is a fairly common one.  Kinda
predictable to have the problem, if you haven't been down that road a
few times.

On Aug 19, 12:23 pm, Mark Carter <[email protected]> wrote:
> Wow - thanks a million Dan. I changed to using the String(char[],int,int)
> constructor instead of String.substring() (and also removed an unnecessary
> trim() per line) and the parse time is now 30ms (compared to 400ms)!
>
> The fact the file is still a CSV is perfect because I can more easily
> debug/maintain that compared to some encoded format.
>
> On 19 August 2010 17:46, DanH <[email protected]> wrote:
>
> > The trick is to avoid any substringing while parsing.  Read into a
> > char array and then use String(char[] value, int offset, int count)
> > to construct the individual string, after parsing its bounds.  And you
> > can speed that up by also having another file that is a "dope
> > vector" (int[]) for the string locations in the char file.
>
> > In fact, for some uses you could forgo the construction of the strings
> > until they're referenced, using the dope vector.
>
> > On Aug 19, 10:01 am, Mark Carter <[email protected]> wrote:
> > > I've got a map of about 500 entries. Strings are all very short (less
> > > than 5 chars).
>
> > > Its read-only data I want to read once at app-startup.
>
> > > What's the best way to store this so that loading this data is fast?
>
> > > I've tried storing the data in a CSV in res/raw but this takes about
> > > 700ms to parse on my N1, so I'm hoping there's a faster way...
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]<android-developers%[email protected]>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to