This is a migrated thread and some comments may be shown as answers.

Strange decompiled code

1 Answer 27 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mathias
Top achievements
Rank 1
Mathias asked on 24 May 2012, 01:22 PM
Hi,

while looking for solutions for my issues with the timeline control, I've decompiled the HourInterval class. With JD the static constructor looks like this:
Func<DateTime, string>[] funcArray = new Func<DateTime, string>[2];
Func<DateTime, string>[] func = funcArray;
bool flag = false;
func[flag] = (DateTime date) => date.ToString("hh tt");
Func<DateTime, string>[] func1 = funcArray;
bool flag1 = true;
func1[flag1] = (DateTime date) => date.ToString("ht");
HourInterval.formatters = funcArray;

Using another decompile tool it looks like this:
Func<DateTime, string>[] array = new Func<DateTime, string>[2];
array[0] = ((DateTime date) => date.ToString("hh tt"));
array[1] = ((DateTime date) => date.ToString("ht"));
HourInterval.formatters = array;

I don't know the original code so can't tell if both are equally "correct", but the second result is much easier to read and understand. Is this difference intentional?

Regards,
Mathias

1 Answer, 1 is accepted

Sort by
0
Nikolay G Rusev
Telerik team
answered on 31 May 2012, 12:49 PM
Hi Mathias,

 Thank you for the feedback and sorry for the delayed response. While there is definitely room for improvements in code readability, this issue has fairly low priority at this moment.
That aside, in the example you have given, the usage of boolean variables as array indexers is wrong. We've logged this bug, so it should be fixed in some of our forthcoming releases.

Kind regards,
Nikolay G Rusev
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
General Discussions
Asked by
Mathias
Top achievements
Rank 1
Answers by
Nikolay G Rusev
Telerik team
Share this question
or