Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QScriptEngine: which expression is faster ?
Forum Updated to NodeBB v4.3 + New Features

QScriptEngine: which expression is faster ?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 601 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dextermagnific
    wrote on last edited by dextermagnific
    #1

    Hi Everybody,

    I'm making a scriptable application, and I'm wondering which kind of expression is faster:

    engine.evaluate("object1.property1").toString();
    engine.evaluate("object1.property2").toString();
    engine.evaluate("object1.property3").toString();
    

    or

    QScriptValue object1 = engine.property("object1");
    object1.property("property1").toString();
    object1.property("property2").toString();
    object1.property("property3").toString();
    

    Is the second method faster (I 'save' object1 and I'm hoping that property() does not invoke the interpreter). ? I'm I right ?

    Thanks

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi. Why don't you just measure and see what's faster?

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dextermagnific
        wrote on last edited by
        #3

        Possible answer: it's the same.
        Either property() invokes the interpreter or object1 is "changed" everytime the underlying script changes it.

        Because if I do:

        // let's assume object1 is an array
        QScriptValue object1= engine.property("object1");
        

        Then I use Javascript to alter the contents of object1 (for example using evaluate())

        and I do:

        qDebug() << object1.toVariant();
        

        The object1 will contains the latest changes, even if it has been changes outside C++.

        This makes me believe that QScriptValue objects are tied to the underlying JS objects. Any change in the JS will immediately be seen in C++.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved