Results 1 to 40 of 301

Thread: The 1001 questions about vbRichClient5 (2020-07-21)

Hybrid View

  1. #1
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,454

    Re: The 1001 questions about vbRichClient5 (2020-02-08)

    Quote Originally Posted by wqweto View Post
    Just for the experiment I just impl a VbPeg based JS tokenizer w/ the requirements of the RE "competition" but also one that strips whitespace outside of string literals (minifies JS) and it turned quite fast
    Nice...

    FWIW, here's a performance-improvement for the ActiveScript-JSCode based replacements
    (which also corrects a few errors in the reg-expressions):

    Code:
        With New_c.StringBuilder 
           .AppendNL "'use strict';"
           .AppendNL "var regCmtSngLine1 = /(^\/\/.*?(\r|\n))/gm ;"
           .AppendNL "var regCmtSngLine2 = /(?!([""']([^\\[""']]*).*[""'])).(\/\/.*?(\r|\n))/g ;"
           .AppendNL "var regCmtMultiLine = /(\/\*[\w\'\s\r\n\*]*\*\/)/g ;"
     
           .AppendNL "var regLet = /^\s*[\{\(]*let \b/gm ;"
           .AppendNL "var regEmptyLines = /^\s*[\r\n]/gm ;"
     
           .AppendNL "function CompressJavaScript(code){"
           .AppendNL "  return code"
           .AppendNL "         .replace(regCmtSngLine1,'')"
           .AppendNL "         .replace(regCmtSngLine2,'')"
           .AppendNL "         .replace(regCmtMultiLine,'')"
           .AppendNL "         .replace(regLet,'var ')"
           .AppendNL "         .replace(regEmptyLines,'')"
           .AppendNL "}"
           mSC.AddCode .ToString
        End With
    With these changes it is now faster than the (VB)Scripting-Regex-Code -
    (also note, that "JScript" works - surprisingly - a bit faster than the newer "JScript9" engine).

    Olaf

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Re: The 1001 questions about vbRichClient5 (2020-02-08)

    Quote Originally Posted by Schmidt View Post
    Nice...

    FWIW, here's a performance-improvement for the ActiveScript-JSCode based replacements
    (which also corrects a few errors in the reg-expressions):

    Code:
        With New_c.StringBuilder 
           .AppendNL "'use strict';"
           .AppendNL "var regCmtSngLine1 = /(^\/\/.*?(\r|\n))/gm ;"
           .AppendNL "var regCmtSngLine2 = /(?!([""']([^\\[""']]*).*[""'])).(\/\/.*?(\r|\n))/g ;"
           .AppendNL "var regCmtMultiLine = /(\/\*[\w\'\s\r\n\*]*\*\/)/g ;"
     
           .AppendNL "var regLet = /^\s*[\{\(]*let \b/gm ;"
           .AppendNL "var regEmptyLines = /^\s*[\r\n]/gm ;"
     
           .AppendNL "function CompressJavaScript(code){"
           .AppendNL "  return code"
           .AppendNL "         .replace(regCmtSngLine1,'')"
           .AppendNL "         .replace(regCmtSngLine2,'')"
           .AppendNL "         .replace(regCmtMultiLine,'')"
           .AppendNL "         .replace(regLet,'var ')"
           .AppendNL "         .replace(regEmptyLines,'')"
           .AppendNL "}"
           mSC.AddCode .ToString
        End With
    With these changes it is now faster than the (VB)Scripting-Regex-Code -
    .
    Wonderful. I'll upload a new test program in a while. Thank you very much, Olaf.

    Quote Originally Posted by Schmidt View Post
    (also note, that "JScript" works - surprisingly - a bit faster than the newer "JScript9" engine).
    This is really good news for me because I use JScript more than JScript9.

  3. #3
    Addicted Member
    Join Date
    Apr 2017
    Location
    India
    Posts
    238

    Re: The 1001 questions about vbRichClient5 (2020-02-08)

    Quote Originally Posted by Schmidt View Post
    Nice...

    FWIW, here's a performance-improvement for the ActiveScript-JSCode based replacements
    (which also corrects a few errors in the reg-expressions):

    Code:
        With New_c.StringBuilder 
           .AppendNL "'use strict';"
           .AppendNL "var regCmtSngLine1 = /(^\/\/.*?(\r|\n))/gm ;"
           .AppendNL "var regCmtSngLine2 = /(?!([""']([^\\[""']]*).*[""'])).(\/\/.*?(\r|\n))/g ;"
           .AppendNL "var regCmtMultiLine = /(\/\*[\w\'\s\r\n\*]*\*\/)/g ;"
     
           .AppendNL "var regLet = /^\s*[\{\(]*let \b/gm ;"
           .AppendNL "var regEmptyLines = /^\s*[\r\n]/gm ;"
     
           .AppendNL "function CompressJavaScript(code){"
           .AppendNL "  return code"
           .AppendNL "         .replace(regCmtSngLine1,'')"
           .AppendNL "         .replace(regCmtSngLine2,'')"
           .AppendNL "         .replace(regCmtMultiLine,'')"
           .AppendNL "         .replace(regLet,'var ')"
           .AppendNL "         .replace(regEmptyLines,'')"
           .AppendNL "}"
           mSC.AddCode .ToString
        End With
    With these changes it is now faster than the (VB)Scripting-Regex-Code -
    (also note, that "JScript" works - surprisingly - a bit faster than the newer "JScript9" engine).

    Olaf
    Dear Olaf,

    First of all, I wish you a Very Happy New Year. Its always a great feeling, wishing an extremely magnanimous soul like you, as my heart wells up with gratitude. And, I take this opportunity to wish a Happy New Year to all the great masters and experts of our VbForums through whom countless many (which includes me also naturally) have got benefited and in turn passed on those benefits, in one way or other, to a further 'countless many' of the society, like a positive chain reaction.

    Well, the following are in reference to this post of mine - https://www.vbforums.com/showthread....=1#post5627131 - Post #51
    --
    1. Is there any way of using ActiveScript to specify a language which would allow me to use LookBehinds in regular expressions?

    2. ActiveScript was able to accept 'Chakra' as language. It did not seem to accept 'V8' as language though, as the language got automatically set as 'Jscript9' by your ActiveScript (as it was the case with any other random string I passed to it as language).

    3. I tried WV.jsRun too, just to see what happens. It accepts lookbehinds in regex patterns, obviously. But, it was quite slow. May be it can be done in a way to make it run fast but I did not know how. Using jsRunAsync did not seem to be the right way to effect faster regex operations.
    --

    So, is there any way at all, as of today, either through ActiveScript or WV or any other technology, to use a flavour of JS, which, like pcre2, can effect regex operations with all the allowed specifications (incl. Lookbehinds, groups, etc. [since the 2018 ECMAScript specs, as I get to understand from the net]) and also effect such regex operations as fast as wonderful JpBro's Pcr wrapper (OR) your ActiveScript Js (OR) VB RegEx.

    Thanks in tons, once again, for all your free offerings to the society.

    Kind Regards.

    Edit-1:
    Just now, after posting the above, I checked out my referred post in JpBro's thread and I notice a new reply therein, from you!!!, Olaf. I will now go and read that fully.

    Edit-2:
    First of all, as ever, thanks a lot for your reply in JpBro's thread. I had not made that init/reinit optimisation (as in your code) in 'pcrTest' either. So, I started to make them (so that my future benchmarking will be on even scales). And, "to whatever level I could" do^ the optimisation, with my limited knowledge, and "to whatever level I have tested so far", as per my initial findings, I see a dramatic increase in processing speed in JpBro's pcrTest, w.r.t the non-English database. Once I have done a thorough testing for both non-English and English databases, I will share my results in JpBro's thread. At that time, I would request you to kindly help me know (if possible and if and when you find time) the ideal manner in which the pcrTest code shall be, so that it will carry the highest optimisation. In case my initial findings prove later to be not correct, I shall inform that also here. Thank you soooooo much once again for taking time, even amidst your hectic schedules, to give such clear-cut code snippets. Remaining in all humbleness, as always.
    (^) I dont know whether I have handled the memory free-ings correctly. That's one more reason for which I have requested your kind help above. I wanted to post pcrTest code in my last reply in JpBro's thread itself but forgot.

    Edit-3: The weblink I gave to "my post in JpBro's thread" was not working correctly because of the closing bracket getting added to the link, upon clicking it. So, I removed the enclosing brackets now. Also, mentioned the post no.

    Last edited by softv; Jan 1st, 2024 at 03:50 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width