Re: Efficiently streaming data to associative array

2017-08-10 Thread Jon Degenhardt via Digitalmars-d-learn
On Wednesday, 9 August 2017 at 13:36:46 UTC, Steven Schveighoffer wrote: On 8/8/17 3:43 PM, Anonymouse wrote: On Tuesday, 8 August 2017 at 16:00:17 UTC, Steven Schveighoffer wrote: I wouldn't use formattedRead, as I think this is going to allocate temporaries for a and b. What would you sugge

Re: Efficiently streaming data to associative array

2017-08-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/8/17 3:43 PM, Anonymouse wrote: On Tuesday, 8 August 2017 at 16:00:17 UTC, Steven Schveighoffer wrote: I wouldn't use formattedRead, as I think this is going to allocate temporaries for a and b. What would you suggest to use in its stead? My use-case is similar to the OP's in that I have

Re: Efficiently streaming data to associative array

2017-08-09 Thread Guillaume Chatelet via Digitalmars-d-learn
On Wednesday, 9 August 2017 at 10:00:14 UTC, kerdemdemir wrote: As a total beginner I am feeling a bit not comfortable with basic operations in AA. First even I am very happy we have pointers but using pointers in a common operation like this IMHO makes the language a bit not safe. Second "

Re: Efficiently streaming data to associative array

2017-08-09 Thread kerdemdemir via Digitalmars-d-learn
I haven't yet dug into formattedRead but thx for letting me know : ) I was mostly speaking about the pattern with the AA. I guess the best I can do is a templated function to hide the ugliness. ref Value GetWithDefault(Value)(ref Value[string] map, const (char[]) key) { auto pValue = key i

Re: Efficiently streaming data to associative array

2017-08-08 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 8 August 2017 at 16:00:17 UTC, Steven Schveighoffer wrote: I wouldn't use formattedRead, as I think this is going to allocate temporaries for a and b. What would you suggest to use in its stead? My use-case is similar to the OP's in that I have a string of tokens that I want split

Re: Efficiently streaming data to associative array

2017-08-08 Thread Guillaume Chatelet via Digitalmars-d-learn
On Tuesday, 8 August 2017 at 16:00:17 UTC, Steven Schveighoffer wrote: On 8/8/17 11:28 AM, Guillaume Chatelet wrote: Let's say I'm processing MB of data, I'm lazily iterating over the incoming lines storing data in an associative array. I don't want to copy unless I have to. Contrived example

Re: Efficiently streaming data to associative array

2017-08-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/8/17 11:28 AM, Guillaume Chatelet wrote: Let's say I'm processing MB of data, I'm lazily iterating over the incoming lines storing data in an associative array. I don't want to copy unless I have to. Contrived example follows: input file -- a,b,15 c,d,12 Efficient ingestion

Efficiently streaming data to associative array

2017-08-08 Thread Guillaume Chatelet via Digitalmars-d-learn
Let's say I'm processing MB of data, I'm lazily iterating over the incoming lines storing data in an associative array. I don't want to copy unless I have to. Contrived example follows: input file -- a,b,15 c,d,12 ... Efficient ingestion --- void main() { size_t[str