On Wednesday, 14 May 2014 at 13:44:40 UTC, John Colvin wrote:
Yes, they are much faster. Normal array indexing is equivalent
to *(myArray.ptr + index) plus an optional bounds check,
whereas associative array indexing is a much, much larger job.
Why were you using associative arrays in the fi
On Wednesday, 14 May 2014 at 13:49:22 UTC, bearophile wrote:
Chris:
foreach (size_t i; 0..myArray.length) {
// do something with myArray[i];
}
There are various better ways to use a foreach on an array:
foreach (immutable x; myArray) {
foreach (ref const x; myArray) {
foreach (ref x; myAr
Chris:
foreach (size_t i; 0..myArray.length) {
// do something with myArray[i];
}
There are various better ways to use a foreach on an array:
foreach (immutable x; myArray) {
foreach (ref const x; myArray) {
foreach (ref x; myArray) {
Bye,
bearophile
On Wednesday, 14 May 2014 at 13:31:53 UTC, dennis luehring wrote:
Am 14.05.2014 15:20, schrieb Chris:
Profiling is not really feasible, because for this to work
properly, I would have to introduce the change first to be able
to compare both. Nothing worse than carefully changing things
only to f
On Wednesday, 14 May 2014 at 13:20:40 UTC, Chris wrote:
On Wednesday, 14 May 2014 at 11:13:10 UTC, John Colvin wrote:
On Wednesday, 14 May 2014 at 09:38:10 UTC, Chris wrote:
I have code that uses the following:
string[][size_t] myArray;
1. myArray = [0:["t", "o", "m"], 1:["s", "m", "i", "th"]
Am 14.05.2014 15:20, schrieb Chris:
Profiling is not really feasible, because for this to work
properly, I would have to introduce the change first to be able
to compare both. Nothing worse than carefully changing things
only to find out, it doesn't really speed up things.
why not using an alia
On Wednesday, 14 May 2014 at 11:13:10 UTC, John Colvin wrote:
On Wednesday, 14 May 2014 at 09:38:10 UTC, Chris wrote:
I have code that uses the following:
string[][size_t] myArray;
1. myArray = [0:["t", "o", "m"], 1:["s", "m", "i", "th"]];
However, I've found out that I never need an assoc ar
On Wednesday, 14 May 2014 at 09:38:10 UTC, Chris wrote:
I have code that uses the following:
string[][size_t] myArray;
1. myArray = [0:["t", "o", "m"], 1:["s", "m", "i", "th"]];
However, I've found out that I never need an assoc array and a
"linear" array would be just fine, as in
2. myArra
Chris:
Do you mean the difference is negligible in many cases?
Yes, but you have to profile the code (or reason about it well,
with knowledge of the data structures and their usage patterns)
if you want to know what your case is.
Bye,
bearophile
Am 14.05.2014 12:33, schrieb Chris:
On Wednesday, 14 May 2014 at 10:20:51 UTC, bearophile wrote:
Chris:
Is there any huge difference as regards performance and memory
footprint between the two? Or is 2. basically 1. under the
hood?
An associative array is a rather more complex data structure
On Wednesday, 14 May 2014 at 10:20:51 UTC, bearophile wrote:
Chris:
Is there any huge difference as regards performance and memory
footprint between the two? Or is 2. basically 1. under the
hood?
An associative array is a rather more complex data structure,
so if you don't need it, use some
Chris:
Is there any huge difference as regards performance and memory
footprint between the two? Or is 2. basically 1. under the hood?
An associative array is a rather more complex data structure, so
if you don't need it, use something simpler. There is difference
in both the amount of memor
I have code that uses the following:
string[][size_t] myArray;
1. myArray = [0:["t", "o", "m"], 1:["s", "m", "i", "th"]];
However, I've found out that I never need an assoc array and a
"linear" array would be just fine, as in
2. myArray = [["t", "o", "m"], ["s", "m", "i", "th"]];
Is there a
13 matches
Mail list logo