Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update JSON.ahk #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

robertlzj
Copy link

Get the character code in hex derectly! Only need to replace "0x" to "\u".
Much faster I think!
Test:

s:=0x12AB
SetFormat, IntegerFast, hex
b:=A_TickCount
    Loop 1000000{
        ;~ y:="\u",n := 12
        ;~ while(n>=0)
            ;~ y.= Chr((x:=(s>>n) & 15) + (x<10 ? 48 : 55))
            ;~ ,n-=4
        ;10438 ms

        y:="\u" SubStr(s,3)
        ;812
    }
MsgBox % A_TickCount-b

I don't know, how to get NumberType of SetFormat for restore later?
My ask in fourm.

Get the character code derectly! Replace "0x" to "\u".
Much faster I think!

I don't know, how to get NumberType of SetFormat for restore later?
I will ask in fourm.
;I don't know, how to get NumberType of SetFormat for restore later?
SetFormat, IntegerFast, hex
while RegExMatch(obj, "[^\x20-\x7e]", ch)
StringReplace, obj, obj, % ch, % "\u" SubStr(Asc(ch),3), A
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't test it.
I had just saw a share of the method above from a post in ahkscript.
I learn much from the few lines (just in scope of while)! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant