Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 737231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:41:51+00:00 2026-05-14T07:41:51+00:00

Is it clean enough that you can discard the PHP and hand-optimize the C++

  • 0

Is it clean enough that you can discard the PHP and hand-optimize the C++ code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:41:52+00:00Added an answer on May 14, 2026 at 7:41 am

    Short answer: no.

    Since I spent some time to get HipHop to work, I decided to share my results here so I don’t feel like a COMPLETE waste of time.

    Here’s my PHP input:

    &lt?
    
    class test {
     function loop() {
      for($i=0; $i<10; ++$i) {
        echo("i = $i\n");
      }
     }
    }
    
    $t = new test();
    $t->loop();
    
    ?>
    
    

    And here’s the C++ output…

    #include <php/hello.h>
    #include <cpp/ext/ext.h>
    
    namespace HPHP {
    ///////////////////////////////////////////////////////////////////////////////
    
    /* preface starts */
    /* preface finishes */
    /* SRC: hello.php line 3 */
    Variant c_test::os_get(const char *s, int64 hash) {
      return c_ObjectData::os_get(s, hash);
    }
    Variant &c_test::os_lval(const char *s, int64 hash) {
      return c_ObjectData::os_lval(s, hash);
    }
    void c_test::o_get(ArrayElementVec &props) const {
      c_ObjectData::o_get(props);
    }
    bool c_test::o_exists(CStrRef s, int64 hash) const {
      return c_ObjectData::o_exists(s, hash);
    }
    Variant c_test::o_get(CStrRef s, int64 hash) {
      return c_ObjectData::o_get(s, hash);
    }
    Variant c_test::o_set(CStrRef s, int64 hash, CVarRef v,bool forInit /* = false */) {
      return c_ObjectData::o_set(s, hash, v, forInit);
    }
    Variant &c_test::o_lval(CStrRef s, int64 hash) {
      return c_ObjectData::o_lval(s, hash);
    }
    Variant c_test::os_constant(const char *s) {
      return c_ObjectData::os_constant(s);
    }
    IMPLEMENT_CLASS(test)
    ObjectData *c_test::cloneImpl() {
      c_test *obj = NEW(c_test)();
      cloneSet(obj);
      return obj;
    }
    void c_test::cloneSet(c_test *clone) {
      ObjectData::cloneSet(clone);
    }
    Variant c_test::o_invoke(const char *s, CArrRef params, int64 hash, bool fatal) {
      if (hash < 0) hash = hash_string_i(s);
      switch (hash & 1) {
        case 1:
          HASH_GUARD(0x0EA59CD1566F5709LL, loop) {
            return (t_loop(), null);
          }
          break;
        default:
          break;
      }
      return c_ObjectData::o_invoke(s, params, hash, fatal);
    }
    Variant c_test::o_invoke_few_args(const char *s, int64 hash, int count, CVarRef a0, CVarRef a1, CVarRef a2, CVarRef a3, CVarR
    ef a4, CVarRef a5) {
      if (hash < 0) hash = hash_string_i(s);
      switch (hash & 1) {
        case 1:
          HASH_GUARD(0x0EA59CD1566F5709LL, loop) {
            return (t_loop(), null);
          }
          break;
        default:
          break;
      }
      return c_ObjectData::o_invoke_few_args(s, hash, count, a0, a1, a2, a3, a4, a5);
    }
    Variant c_test::os_invoke(const char *c, const char *s, CArrRef params, int64 hash, bool fatal) {
      return c_ObjectData::os_invoke(c, s, params, hash, fatal);
    }
    Variant cw_test$os_get(const char *s) {
      return c_test::os_get(s, -1);
    }
    Variant &cw_test$os_lval(const char *s) {
      return c_test::os_lval(s, -1);
    }
    Variant cw_test$os_constant(const char *s) {
      return c_test::os_constant(s);
    }
    Variant cw_test$os_invoke(const char *c, const char *s, CArrRef params, bool fatal /* = true */) {
      return c_test::os_invoke(c, s, params, -1, fatal);
    }
    void c_test::init() {
    }
    /* SRC: hello.php line 4 */
    void c_test::t_loop() {
      INSTANCE_METHOD_INJECTION(test, test::loop);
      int64 v_i = 0;
    
      {
        LOOP_COUNTER(1);
        for ((v_i = 0LL); less(v_i, 10LL); ++v_i) {
          LOOP_COUNTER_CHECK(1);
          {
            echo((LINE(6,concat3("i = ", toString(v_i), "\n"))));
          }
        }
      }
    } /* function */
    Object co_test(CArrRef params, bool init /* = true */) {
      return Object(p_test(NEW(c_test)())->dynCreate(params, init));
    }
    Variant pm_php$hello_php(bool incOnce /* = false */, LVariableTable* variables /* = NULL */) {
      FUNCTION_INJECTION(run_init::hello.php);
      {
        DECLARE_GLOBAL_VARIABLES(g);
        bool &alreadyRun = g->run_pm_php$hello_php;
        if (alreadyRun) { if (incOnce) return true;}
        else alreadyRun = true;
        if (!variables) variables = g;
      }
      DECLARE_GLOBAL_VARIABLES(g);
      LVariableTable *gVariables __attribute__((__unused__)) = get_variable_table();
      Variant &v_t __attribute__((__unused__)) = (variables != gVariables) ? variables->get("t") : g->GV(t);
    
      (v_t = ((Object)(LINE(11,p_test(p_test(NEWOBJ(c_test)())->create())))));
      LINE(12,v_t.o_invoke_few_args("loop", 0x0EA59CD1566F5709LL, 0));
      return true;
    } /* function */
    
    ///////////////////////////////////////////////////////////////////////////////
    }
    

    Yuck! It took me several seconds to even find the loop…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this code is supposed to ensure that clean code gets to the database it
Is there a clean way of cloning a record in SQL that has an
How can i clean and modify data from a form in django. I would
my SQL skills aren't strong enough to figure this out, hope someone can help.
I have to clean up from a list of files the ones that do
I can't quite figure out the right pattern to use with PHP's preg_replace function.
[This is a code coverage question, only that I hope to use it in
I need to clean up a file. We have an xml parser that runs
I have to do some maintenance on legacy code that uses Hungarian notation (and
I have a Python library design that I'm trying to clean up, but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.