Search found 214 matches

by oif2003
13 Dec 2018, 01:05
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

Re: Problems with objects and legacy syntax Topic is solved

Code: Select all

indent(n) => --n ? indent(n) " " : ""
seems to yield immediate improvements!

Edit: disregard. Just my PC being inconsistent.
by oif2003
13 Dec 2018, 00:41
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

Re: Problems with objects and legacy syntax Topic is solved

but ur code would fail[/color] on \t or EOL symbols. any "beautified" json input would crash. and if u add more comparisons it would become slower than regex actually our own beautified output would crash json.get . Try that sample as input data (AHK v2 only syntax): Those are some detailed analysi...
by oif2003
13 Dec 2018, 00:04
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

Re: Problems with objects and legacy syntax Topic is solved

No reasons really, I just picked the first large hex number that came to my mind ;) BTW, it's sitting at exactly 50 lines! class json { ;json.set by vvhitevvizard. json.get by coco and modified by vvhitevvizard get(ByRef _s) { ;obj:=json.get(str) static M:=0x7FFFFFFF, q:=Chr(34), p:={"__Arr":1}, x:...
by oif2003
12 Dec 2018, 23:45
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

Re: Problems with objects and legacy syntax Topic is solved

btw I see uve changed ur mind and returned indent(n) => n ? indent(--n) " " : "" instead of nasty-looking indent(n){ loop(n) _.=" " return _ } Performance of json.set reacts upon this negatively. =) I changed it back because I figure after the static checks the overhead should be constant unless yo...
by oif2003
12 Dec 2018, 23:23
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

Re: Problems with objects and legacy syntax Topic is solved

That was my fault ... I removed that !== "" :facepalm: I think we might be able to replace (SubStr(_s, n) ~= "[\]\},\s]|$")-1 with min(InStr(_s,"]",,n)||M,InStr(_s,"}",,n)||M,InStr(_s,",",,n)||M,InStr(_s," ",,n)||M)-n where M:=0x7FFFFFFF is declared as static inside get Took me a while, but that's ...
by oif2003
12 Dec 2018, 21:56
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

Re: Problems with objects and legacy syntax Topic is solved

Interesting.... didn't realize you are still working on it. I got bored after dinner and tried this: about 10% faster for json.get Two things I want to try: 1)look for replacement of regexmatch (~=), 2) try "loop parse _s" instead of using a while loop Edit: item 2 won't work (or is too much work) ...
by oif2003
12 Dec 2018, 20:14
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

Re: Problems with objects and legacy syntax Topic is solved

vvhitevvizard wrote:
12 Dec 2018, 19:43
We needed that conversion to a pure float when parsing stringified input.

and to the post before: so instead of having any callback for float parsing, trade-off would be Round(v, this.Round).
Sounds like a fine plan to me, but I'm sticking with my format(..., v)! :D
by oif2003
12 Dec 2018, 19:38
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

Re: Problems with objects and legacy syntax Topic is solved

as an afterthought, Round() expects a pure float. So its output is oke'ish. w/o preceding zeroes and . . All we need to do is make sure that if (v is "Number") && Type(v)="String" -> v+=0 to force it pure number again When I tried that it gave me a lot of garbage after the last significant digit. l...
by oif2003
12 Dec 2018, 19:28
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

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 re-benched all the variants. Mine with a closure gives +7%, ur 1st...
by oif2003
12 Dec 2018, 19:08
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

Re: Problems with objects and legacy syntax Topic is solved

vvhitevvizard wrote:
12 Dec 2018, 19:04
another static variable to keep track of last used this.Space and a quick check seems to fix it

Code: Select all

		static q:= Chr(34), ind, space
		(_d || space == this.Space) || (ind := indent(this.Space), space := this.Space)
by oif2003
12 Dec 2018, 19:02
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

Re: Problems with objects and legacy syntax Topic is solved

vvhitevvizard wrote:
12 Dec 2018, 18:51
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
by oif2003
12 Dec 2018, 18:51
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

Re: Problems with objects and legacy syntax Topic is solved

vvhitevvizard wrote:
12 Dec 2018, 18:45
SmartR8() could be just Round(v, 8) (or any n of decimals suitable) just for a performance sake in here.
format("{:g}", 0.1234567) vs Round(8, 0.1234567). 1516 vs 140. Round() is x10 as fast.
But I don't think round(v, 8) handles trailing zeros?
by oif2003
12 Dec 2018, 18:46
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

Re: Problems with objects and legacy syntax 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) " " : ""
Disregard this change, it's too slow! Didn't think there'd be a perceptible difference, but there is!
by oif2003
12 Dec 2018, 18:37
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

Re: Problems with objects and legacy syntax Topic is solved

I knew there's a better way to write that indent function:

Code: Select all

indent(n) => n ? indent(--n) " " : "" 
by oif2003
12 Dec 2018, 18:15
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

Re: Problems with objects and legacy syntax Topic is solved

I could replace if(expression) (expression) with (expression) && (expression) inliners in many places (especially within json.get() ). :D But I meant logic optimization, removing unneeded steps, etc Funny you said that, cuz I got bored and that's exactly what I did lol (among other trivial things) ...
by oif2003
12 Dec 2018, 16:42
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

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) ?

Not really an improvement, but if you remove the this.space option and opt for fixed spacing, (ie: the default 4), you can write that if else block in ternary form.
by oif2003
12 Dec 2018, 15:25
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

Re: Problems with objects and legacy syntax Topic is solved

Those are nice tweaks! Please do post the complete class somewhere when your done.

If A then B === A && B
If Not A then B === A || B
are pretty standard ways of inlining IF without ELSE in some languages that short circuit && and ||
by oif2003
11 Dec 2018, 21:45
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

Re: Problems with objects and legacy syntax Topic is solved

I'm all AHKed out for the day. I tested a few implementations against a.test.key where key is a 20 element array initialized at 0. obj.str is hard to beat, but I still prefer the better looking version that performs within 10% of obj.str and is usually less than 10x slower than operating directly on...
by oif2003
11 Dec 2018, 19:24
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

Re: Problems with objects and legacy syntax Topic is solved

Another way to do this is to cache the object address. I will try it later when I get a chance. We should start benchmarking it against the plain a.test.key. I think we are only about 8x away
by oif2003
11 Dec 2018, 19:07
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 31797

Re: Problems with objects and legacy syntax Topic is solved

Good point. I prefer the self initializing version so I can put it anywhere. Maybe I can combine the two versions above without incurring much penalty. I'll test it out later.

Go to advanced search