sonygod / sharpkit

Automatically exported from code.google.com/p/sharpkit
0 stars 0 forks source link

New Array with fixed length does not initialize the length #145

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
c#:
        public static T[] toArray<T>(this HashSet<T> self) {
            var ar = new T[self.Count];
            return null;
        }

js:
        toArray$1: function(T, self)
        {
            var ar = []; //Should be: var ar = new Array(self.get_Count());
            return null;
        },

Original issue reported on code.google.com by DanelK...@gmail.com on 15 Jun 2012 at 7:38

GoogleCodeExporter commented 9 years ago
Explictly constructed arrays also suffer from this problem e.g.

c#:

var someInts = new int[5];
console.log(someInts.Length);

will produce

var someInts = [];
console.log(someInts.length);

which in turn ends up with awkward to detect bugs.

The explicit array initialization will also help with performance/memory on 
modern JavaScript engines.

Original comment by co...@gravill.com on 3 May 2013 at 12:34

GoogleCodeExporter commented 9 years ago

Original comment by DanelK...@gmail.com on 21 Jun 2013 at 4:57