Search found 405 matches

by vvhitevvizard
12 Dec 2018, 19:43
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

When I tried that it gave me a lot of garbage after the last significant digit. like 102.000000097 I edited my prev. post. We don't need to v+=0 for stringified output. We needed that conversion to a pure float when parsing stringified input. and to the post before: so instead of having any callbac...
by vvhitevvizard
12 Dec 2018, 19:37
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

as an afterthought, Round() expects a pure float (tries to convert to float) and outputs a string. So its oke'ish, w/o preceding zeroes and numbers like 9..
All we need to do is make sure that (v is "Number") (is convertible to a number) before calling Round()
by vvhitevvizard
12 Dec 2018, 19:31
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

oif2003 wrote:
12 Dec 2018, 19:28
my callback function is... format("{:g}", v) !
haha nice joke. :D
method should look like set(_o, _f:=""){ ;object, callback but calling out an outer function for any value would drastically reduce performance. I tested it
by vvhitevvizard
12 Dec 2018, 19:24
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

But I don't think round(v, 8) handles trailing zeros? It cannot but for json to/from conversions its ok. :) Ultimately It should be a user callback function. :) the same way replacer() / reviver() do it for its JS counterpart. btw I realized I used different loop counts so I re-benched all the vari...
by vvhitevvizard
12 Dec 2018, 19:12
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

oif2003 wrote:
12 Dec 2018, 19:08
another static variable to keep track of last used this.Space and a quick check seems to fix it
400 -> 375 :thumbup:
by vvhitevvizard
12 Dec 2018, 19:04
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

oif2003 wrote:
12 Dec 2018, 19:02
Thanks! But interestingly, performance gets worse for me using recursion. The slow down over 20k runs ranges from almost none to up to 200 ms
U R RIGHT!
I re-tested it. Indeed, ~400 w/o it, 500 with it. Beautiful line of code, but terrible at run time ))
by vvhitevvizard
12 Dec 2018, 18:51
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: AHK v2 scripts optimization Topic is solved

oif2003 wrote:
12 Dec 2018, 18:37
I knew there's a better way to write that indent function:

Code: Select all

indent(n) => n ? indent(--n) " " : ""
wow! what a beautiful trick; u managed to inline a loop cycle! and performance-wise its NOT getting worse. I learn alot from u =)
by vvhitevvizard
12 Dec 2018, 18:45
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

I did make the indentation (this.Space) loop run only when !_d and gave it a static variable, other than that, I made fthrow method cuz I hate commands! Also replaced SmartR8 with format("{:g}", v), but I imagine you probably want something more robust? First I benchmarked it. 425 vs 500 +15% Well ...
by vvhitevvizard
12 Dec 2018, 18:21
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

I could use a closure (sub-func) and move away all the settings/1-time checks to the outer func: set(_o){ if(!IsObject(_o)){ ;"string" | number if(this.ErrObj) throw Exception("Not an object.", -1) return } d:=e:="" if(this.Compact) n:=d else{ loop(this.Space) e.=" " n:="`n" } q:=Chr(34) ;double-quo...
by vvhitevvizard
12 Dec 2018, 16:48
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

Just out of curiosity, is there a reason you have to use SmartR8() instead of say a RTrim(_a, ".") and format(..., _a) ? Actually it could be replaced with AHK sub-functions and thus improve performance. :D Hehe I told u I wrote this some time ago in a hurry and its this very moment when I looked b...
by vvhitevvizard
12 Dec 2018, 16:16
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

oif2003 wrote:
12 Dec 2018, 15:25
are pretty standard ways of inlining IF without ELSE in some languages that short circuit && and ||
Yeah! it depends on interpreter optimization. I recall Basic language in old times (~1990) that tried to evaluate the right side expression every time. :)
by vvhitevvizard
12 Dec 2018, 15:39
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

Those are nice tweaks! Please do post the complete class somewhere when your done. json.get is unchanged, ;"stringify": format [associative] array (object) as JSON string: str:=json.set(obj) ;by vvhitevvizard ;0=enable indentation and line feed, 1=the most compact representation: static Compact:=0 ...
by vvhitevvizard
12 Dec 2018, 14:58
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

btw, I noticed u like to use "inline if" construction (condition) && (expression) . I used another: (condition) ? (expression):0 (ternary operator with 0 as 3rd operand) a ? k:="value":0 vs a && k:="value" Urs seems to be 10% as fast: 344 vs 313 :D And concerning optimization of json.set method in t...
by vvhitevvizard
11 Dec 2018, 19:43
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

offtopic, right now I'm trying to optimize json.set "json.stringify" functionality (mine from the scratch) and json.get "json.parse" (heavily changed coco 's version from this forum). the code below takes a sample of json-string j:='{"r1":{"r2":{"type1":11,"type2":11},"misc":12}, "type":"ask","price...
by vvhitevvizard
11 Dec 2018, 19:26
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

we might increase performance by setting capacity for the array used: m.SetCapacity(1000) oh nvm it doesn't work with StrSplit() . well, another way is to use Loop Parse and move thru it instead of creating an additional array with StrSplit() . But usual level of nestedness in the case shouldn't be ...
by vvhitevvizard
11 Dec 2018, 19:15
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

Small modification: use memoization to avoid unneeded string/array manipulation version1: saving only last string and array I like the way it goes. Results for a.b.c.key : 2406 | 1781 | 2047 : 3000000 But now u try to hone it for the benchmark where we use only 1 address :D 2nd variant with diction...
by vvhitevvizard
11 Dec 2018, 19:00
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

and unlike prototype class definition last version's class instance deref has to be initiated with-in auto-execute code area and declared as global global deref:=new {__Set:(_,s,v)=>%(m:=StrSplit(s,".")).RemoveAt(1)%[m*]:=v , __Get:(_,s)=>%(m:=StrSplit(s,".")).RemoveAt(1)%[m*]} otherwise deref becom...
by vvhitevvizard
11 Dec 2018, 17:37
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

Kind of hard to beat obj.str version, god I hate that dot! I can't wait for lexikos to extend fat arrow support to property "half-methods" ;) I guess (correct me if I'm wrong) metafunctions just don't work for prototype classes and objects created with {} thats why we need to instantiate it first. ...
by vvhitevvizard
11 Dec 2018, 17:32
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

wow! now u got rid of the 2nd global! :D And we got rid of static statements in the bargain - I didn't even pay any attention
Comparing the length to fat arrow function, I think we've done quite well!
yeah. deref[] variant is preferable imho, it feels just right and logic. tho a bit slower
by vvhitevvizard
11 Dec 2018, 17:26
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 32885

Re: Problems with objects and legacy syntax Topic is solved

oif2003 wrote:
11 Dec 2018, 17:23
Now one!
:D 1 but actually a very long one - I would split in 2. and still 2 globals. can't we dispense with the class instantiation?

about runtime speed - as expected it didn't change b/c we didnt change in methods' logic since then: 2203 | 2000 | 1859 : 3000000

Go to advanced search