Skip to content

Deprecate any Number constructor #45

@Bixilon

Description

@Bixilon

Just found some memory hell (I finally switched to upstream glm again from my fork after all the time) and fixed it in 0c90ac2.

I have two ideas:

The first one is removing (or deprecating) all constructors or parameters wich use a Number type. This wraps the primitive in an object (could be quite breaking though).

The second one is (at least for constructors) remove them too and replace them with inlined companion invoke operator functions:

previously:

class Vec1i(val x: Int) {
 
 constructor(x: Number): this(x.i)
}

now (no Number allocation):

class Vec1i(val x: Int) {
 
  companion object {
   inline operator fun Vec1i.Companion.invoke(x: Number) = Vec1i(x.i)
  }
}

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions