_ Once is slower than non-once, because _ Once adds some condition judgment and searches for it in the Zend internal hash table. It contains only when it cannot be found,
See the http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_vm_def.h for the code section? View = Markup
The key transcript is as follows:
Switch (z_lval (opline-> op2.u. Constant ))...{
Case zend_include_once:
Case zend_require_once :...{
Zend_file_handle file_handle;
Char CWD [MAXPATHLEN];
Cwd_state state;
If (is_absolute_path (z_strval_p (inc_filename), z_strlen_p (inc_filename )))...{
CWD [0] = '';
} Else if (! Vcwd_getcwd (CWD, MAXPATHLEN ))...{
CWD [0] = '';
}
State. cwd_length = strlen (CWD );
State. CWD = zend_strndup (CWD, state. cwd_length );
Failure_retval = (! Virtual_file_ex (& state, z_strval_p (inc_filename), null, 1 )&&
Zend_hash_exists (& EG (included_files), State. CWD, state. cwd_length + 1 ));
Free (State. CWD );
If (failure_retval )...{
/** // * Do nothing */
} Else if (success = zend_stream_open (z_strval_p (inc_filename), & file_handle tsrmls_cc ))...{
If (! File_handle.opened_path )...{
File_handle.opened_path = estrndup (z_strval_p (inc_filename), z_strlen_p (inc_filename ));
}
If (zend_hash_add_empty_element (& EG (included_files), file_handle.opened_path, strlen (file_handle.opened_path) + 1) = success )...{
New_op_array = zend_compile_file (& file_handle, (z_lval (opline-> op2.u. Constant) = zend_include_once? Zend_include: zend_require) tsrmls_cc );
Zend_destroy_file_handle (& file_handle tsrmls_cc );
} Else ...{
Zend_file_handle_dtor (& file_handle );
Failure_retval = 1;
}
} Else ...{
If (z_lval (opline-> op2.u. Constant) = zend_include_once )...{
Zend_message_dispatcher (zmsg_failed_include_fopen, z_strval_p (inc_filename ));
} Else ...{
Zend_message_dispatcher (zmsg_failed_require_fopen, z_strval_p (inc_filename ));
}
}
}
Break;
Case zend_include:
Case zend_require:
New_op_array = compile_filename (z_lval (opline-> op2.u. Constant), inc_filename tsrmls_cc );
Break;
Case zend_eval :...{
Char * eval_desc = zend_make_compiled_string_description ("eval () 'd code" tsrmls_cc );
New_op_array = zend_compile_string (inc_filename, eval_desc tsrmls_cc );
Efree (eval_desc );
}
Break;
Empty_switch_default_case ()
}