• There won't be tokens, because Espruino automatically converts them back to readable text before output - also the function you uploaded doesn't actually contain any reserved words :)

    Try:

    E.setFlags({pretokenise:1});
    function test() {
      for(var i=0;i<10;i++) {
        print(i);
      }
    }
    dump();
    

    This prints:

    function test() {for(var i=0;i<10;i++){print(i);}}
    E.setFlags({ "deepSleep": 0, "pretokenise": 1, "unsafeFlash": 0, "unsyncFiles": 0 });
    

    You'll notice all the whitespace is gone - that happened inside Espruino rather than being anything the IDE did.

    Also if you really want to dive around in the internals:

    >trace(test)
    #30[r1,l1] Function {
      #29[r1,l2] Name String [1 blocks] "\xFFcod"    #38[r1,l0] FlatString [3 blocks] "\xA7(\xACi=0;i<10;i\x98){print(i);}"
      #22[r1,l2] Name String [1 blocks] "\xFFlin"= int 3
    }
    

    So the function code is now "\xA7(\xACi=0;i<10;i\x98){print(i);}" - so you can see for/var/++ have been replaced by character codes>127.

    Just as a quick test:

    E.setFlags({pretokenise:0});
    function test() {
      var t = getTime();
      for(var i=0;i<10;i++) {    
        for(var j=0;j<500;j++) { /* This is a big comment in my code */ };
      }
      print(getTime()-t,process.memory().usage­);
    }
    test();
    E.setFlags({pretokenise:1});
    function test() {
      var t = getTime();
      for(var i=0;i<10;i++) {
        for(var j=0;j<500;j++) { /* This is a big comment in my code */ };
      }
      print(getTime()-t,process.memory().usage­);
    }
    test();
    // gives
    0.79599380493 51  // off
    0.70184040069 47 // on
    

    So in something like that you're about 10% faster and you saved a few variables too

About

Avatar for Gordon @Gordon started