Search found 213 matches

by oif2003
14 Dec 2018, 22:44
Forum: Scripts and Functions
Topic: Pascal's triangle
Replies: 5
Views: 1102

Re: Pascal's triangle

I remember seeing this in a Statistics class:
https://en.wikipedia.org/wiki/Binomial_distribution
You can get the binomial expansion terms from Pascal's Triangle. It's pretty cool how you can let the variables represent the outcomes then simply raise it to whatever power and count the occurrences.
by oif2003
14 Dec 2018, 22:27
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

Re: AHK v2: converting/optimizing scripts Topic is solved

Nicely done! Being a one liner sorta makes up for it :D I did some investigating and found this in the AHK manual: Even faster performance can be achieved by looking up the function's address beforehand. For example: ; In the following example, if the DLL isn't yet loaded, use LoadLibrary in place o...
by oif2003
14 Dec 2018, 18:49
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

Re: AHK v2: converting/optimizing scripts Topic is solved

Hey, I've been a little busy and haven't had the chance to read all your posts in detail yet. Before I get busy again I want to show you this quick script I threw together. It parses the script file for C code and uses TCC (https://bellard.org/tcc/) to generate the object file, then it reads it into...
by oif2003
14 Dec 2018, 00:50
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

Re: Problems with objects and legacy syntax Topic is solved

One time I used json to store files inside ahk script's block comment section preserving file directory structure. In that situation, being able to go 4 deep is kind of nice. Also I might use json to autoload objects into memory on script load and autosave on exit to give the script a persistent fee...
by oif2003
14 Dec 2018, 00:33
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

Re: Problems with objects and legacy syntax Topic is solved

That looks interesting, are you planning on limiting it to say 64 levels? I suppose you can always extend it for more. I messed around with using an array push/pop to track object type, but it was too slow, slower than your implementation. Also just fooling around with older version of the code...th...
by oif2003
13 Dec 2018, 20:38
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

Re: Problems with objects and legacy syntax Topic is solved

vvhitevvizard wrote:
13 Dec 2018, 20:34
Nice! it's one step closer to perfection! :bravo:
by oif2003
13 Dec 2018, 19:20
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

Re: Problems with objects and legacy syntax Topic is solved

Ain't that weird... when benching json string without tabs and newlines, 1.1 is faster. It's the other way around when I feed them json with tabs and newlines. Oh well, so much for loop parse then. On the bright side, one can always add a few more lines of code. Loop parse takes only 2 lol My C has ...
by oif2003
13 Dec 2018, 19:10
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

Re: Problems with objects and legacy syntax Topic is solved

Same result for me. Try feeding both the same json strings with newlines and tabs. This is weird. Loop parse should be faster, too. As to how much, I do not know, but tested independently loop parse was several times faster than while loop.
by oif2003
13 Dec 2018, 19:00
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

Re: Problems with objects and legacy syntax Topic is solved

Hey, it's not the same string if u remove all the space, at least my tests give different results.
by oif2003
13 Dec 2018, 18:50
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

Re: Problems with objects and legacy syntax Topic is solved

What? You mean to tell me my json.get is neither readable nor flexible?! :lol: I benched it. It gets worse CPUtime-wise. 937 vs 844 And the code becomes increasingly more difficult to edit. I have some ideas of optimizing its logic still. Actually it scores 955 with 1 line looper (ur code intact) a...
by oif2003
13 Dec 2018, 18:30
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

Re: Problems with objects and legacy syntax Topic is solved

The only concern here is not to lose completely 2 important things: algorithms readability and ability to be edited ad-hoc. What? You mean to tell me my json.get is neither readable nor flexible?! :lol: Get(ByRef _s){ static q:=Chr(34), p:={"__Arr":1}, x:=q "{[0123456789-" n:=0, k:="", kf:=0, s:=[b...
by oif2003
13 Dec 2018, 17:43
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

Re: Problems with objects and legacy syntax Topic is solved

I think loop parse takes off a modest 5-10% but only if you replace c with A_LoopField. We could just assign c:=A_LoopField once in the top of the cycle and be done with it. =) Try it, it didn't work for me, as that was the first thing I did ;) Seems like it must be updated on every iteration where...
by oif2003
13 Dec 2018, 17:33
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

Re: Problems with objects and legacy syntax Topic is solved

Loop parse beats while loop by a lot in my simple benchmark. But that's before you load it down with actual work. I didn't think about replacing other bits with loop parse. I tested InStr("ab", x) vs x="a"||x="b" and I remember InStr being faster, so I left them alone. I merged all the single lines,...
by oif2003
13 Dec 2018, 17:14
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

Re: Problems with objects and legacy syntax Topic is solved

The things we do for speed/readability! I haven't noticed a decrease in speed from all the spaces and parenthesis I added. I think loop parse takes off a modest 5-10% but only if you replace c with A_LoopField. We might be reaching the point of diminishing returns; there might not be much more fat ...
by oif2003
13 Dec 2018, 16:46
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

Re: Problems with objects and legacy syntax Topic is solved

return(m:=s ? (n RTrim(s, "," n) n _d):"", a ? "[" m "]":"{" m "}") ;wrap to brackets good idea on the paper. BUT it adds 1 additional assignment m:= (with redundant chars copying) so actually its either the same cputime-wise for short substrings or makes code even much slower for long substrings. ...
by oif2003
13 Dec 2018, 15:21
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

Re: Problems with objects and legacy syntax Topic is solved

Stupid me, I missread what you wrote :facepalm: I finally broke down and adjusted it to use loop parse. I also reindented the code so hopefully I didn't break anything doing that class json{ ;json.get by coco and heavily modified by vvhitevvizard and oif2003 ;json.set by vvhitevvizard and heavily m...
by oif2003
13 Dec 2018, 12:01
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

Re: Problems with objects and legacy syntax Topic is solved

Good catch! (_d) || space == this.Space ;if !_d then if space != this.Space || ind := indent(space := this.Space) ;then ... If you remove space==this.Space, indent() will be called on every non-recursive call of json.set adjusted this in json.set(): combined conditionals on (a) return (m := s ? (n ...
by oif2003
13 Dec 2018, 01:18
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

Re: Problems with objects and legacy syntax Topic is solved

What if we just make this.Space a literal string... like
" "
means 4 spaces lol
by oif2003
13 Dec 2018, 01:13
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

Re: Problems with objects and legacy syntax Topic is solved

Still not good enough :( n := 200000 indent1(n) => --n ? indent1(n) " " : "" indent2(n) => n ? indent2(--n) " " : "" indent3(n) { loop n s .= " " return s } t:=A_TickCount loop(n) indent1(4) a1:=A_TickCount-t t:=A_TickCount loop(n) indent2(4) a2:=A_TickCount-t t:=A_TickCount loop(n) indent3(4) a3:=A...
by oif2003
13 Dec 2018, 01:05
Forum: Ask For Help
Topic: AHK v2: converting/optimizing scripts Topic is solved
Replies: 266
Views: 19867

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.

Go to advanced search