Welcome Guest, Not a member yet? Register   Sign In
[possible optimization] Info Request about loading views
#1

[eluser]marcalj[/eluser]
Hello everybody!

I'm worried about the proceeding of loading views. I see that the loader is duplicating a lot of data in the proceeding.

I don't know exactly how internally PHP manage the memory. Probably would be better to use more references creating new variables or catching it in the function definition.

Example:

In Loader.php (page 551) replace
Code:
// Set the default data variables
        foreach (array('view', 'vars', 'path', 'return') as $val)
        {
            $$val = ( ! isset($data[$val])) ? FALSE : $data[$val];
        }
for
Code:
foreach( array('view', 'vars', 'path', 'return') as $val )
{
    if( isset($data[$val]) )
    {
        $$val = &$data[$val];
    }
    else
    {
        $$val = FALSE;
    }
}
Note the "&" for "linking" memory.

This is one example of how to increase performance. Do I am right?

I find confusing the loader method because in my controllers I send a lot of "memory" to views:
Code:
$this->load->view( "example_view", $this->vAlotOfData );
. I can access in views with "$this" and the separated variables... so I find strange the loader method.

What do you think?

Have a nice day Smile
#2

[eluser]Mirage[/eluser]
I think the 'referencing' is overrated and quite misunderstood.

PHP doesn't 'copy' your data by default in PHP4+. This only happens when you actually 'modify' the item. So if the goal is not to modify the result of a function, or have a function modify a passed parameter, or having access to a shared object, passing/assigning byref doesn't give you a measurable benefit at all.




Theme © iAndrew 2016 - Forum software by © MyBB