Results 1 to 1 of 1

Thread: Dynamic method for speed optimisation

  1. #1
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Thanked 1,084 Times in 753 Posts

    Dynamic method for speed optimisation

    I am currently porting some JavaScript code and I don't know the best way to port over such code:

    PHP Code:
    function verySlowCalculationOnlyDoThisOnce() {
    console.log("logging slow calculation");

    Test = function(name) {

    Object.assign(Test.prototype, {
    hello: function() {
    console.log("hello "

    bye: (function() {
    byeMessage verySlowCalculationOnlyDoThisOnce();
            return function() {
    byeMessage ", " "!";
    The bye method basically prepares a part of the return value only once, every test = new Test("you") will reuse the result of the slow function.

    How to rewrite such code for TypeScript?

    The actual real life example is this:

    The three Vec3 are allocated once to prevent garbage collection.
    timescale 0.01

  2. The Following User Says Thank You to kung foo man For This Useful Post:

    kubislav23 (24th November 2018)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts