[OpenLayers-Dev] Re: [OpenLayers 3] type instantiation performance

Peter Robins openlayers at peterrobins.co.uk
Sun Oct 17 12:22:12 EDT 2010


On 17 October 2010 12:24, Eric Lemoine <eric.lemoine at camptocamp.com> wrote:
> To illustrate again how things would look like with what I'm
> proposing, here's an example involving OL.Layer and OL.Layer.Vector,
> assuming the latter inherits from the former:
>
> OL.Layer = function(options) {
>    // constructor
>    ...
> };
> OL.Layer.prototype = {
>    // prototype
>    ...
> }
> OL.Layer.Vector = function(options) {
>     OL.Layer.call(this, options);
>     ...
> };
> OL.inherit(OL.Layer.Vector, OL.Vector, {
>     // prototype
>     ...
> });

um, shouldn't that read:
 OL.inherit(OL.Layer.Vector, OL.Layer, {

ok, so the first 2 statements would be in the OL.Layer file, and the
2nd 2 in OL.Layer.Vector

> I don't think this is such a major change. It would basically just
> involve changing a few lines in all the files including class
> definitions. But maybe you see this as a major change for other
> aspects?

no, actually, thinking about it some more, I don't think it would be a
major change, as the user/programmer would continue to write:

myLayer = new OL.Layer.Vector();

and wouldn't need to bother how inheritance is handled internally

> As Andreas said, we could also address the overhead issue by using
> object litterals

yes, agreed. Projection is another example.


More information about the Dev mailing list