cureos/mdcm — Issue #1: Incorrect implementation of GetDoubleList(), inefficient implementation of GetDoubles() in DcmDecimalFormat
Author: cureos
Created: 2012-01-30 11:09:22+00:00
State: open

The implementation of `GetDoubles()` in `DcmDecimalFormat`, https://github.com/cureos/mdcm/blob/NET_4_0/Dicom/Data/DcmElement.cs#L1073, is highly inefficient. For every new value with index `i` in the array, the method calls `GetDouble(i)`. This method in turn calls `GetValue(i)` to access and parse the string item at position `i`. But with every call of `GetValue(i)`, the entire DS element is read and split into individual item using `GetValues()`.
The obvious implementation would instead be to call `GetValues()`once and for all in `GetDoubles()` and make the double parsing of the individual items within `GetDoubles()`.

The implementation of `GetDoubleList()` in `DcmDecimalFormat`, https://github.com/cureos/mdcm/blob/NET_4_0/Dicom/Data/DcmElement.cs#L1081, is outright wrong. The list is first initialized to a capacity equal to the value multiplicity. However, this is not the same as *setting the size* of the list to this value, the list size is initially zero. The loop over the `.Count` items in the list will thus be an empty loop:

List vals = new List(GetVM());
for(int i = 0; i < vals.Count; i++) {
vals[i] = GetDouble(i);
}

A correct implementation could instead incorporate creating the list from the `GetDoubles()` array, in particular if this implementation is made more efficient...

The methods`GetFloats()`, `GetFloatList()`, `GetDecimals()` and `GetDecimalList()` also suffer from the same issues as the above.