Skip to content

Commit

Permalink
Minor optimization in h()
Browse files Browse the repository at this point in the history
Minor optimizations in FormHelper, as calls to ArrayAccess methods are avoided now.
  • Loading branch information
markstory committed Nov 28, 2010
1 parent 7bfdbff commit e40ee25
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
6 changes: 1 addition & 5 deletions cake/basics.php
Expand Up @@ -186,11 +186,7 @@ function h($text, $double = true, $charset = null) {
if (is_string($double)) {
$charset = $double;
}
if ($charset) {
return htmlspecialchars($text, ENT_QUOTES, $charset, $double);
} else {
return htmlspecialchars($text, ENT_QUOTES, $defaultCharset, $double);
}
return htmlspecialchars($text, ENT_QUOTES, ($charset) ? $charset : $defaultCharset, $double);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions cake/libs/view/helpers/form.php
Expand Up @@ -243,12 +243,12 @@ function create($model = null, $options = array()) {
if (empty($options['url']['controller'])) {
if (!empty($model) && $model != $this->defaultModel) {
$options['url']['controller'] = Inflector::underscore(Inflector::pluralize($model));
} elseif (!empty($this->request['controller'])) {
$options['url']['controller'] = Inflector::underscore($this->request['controller']);
} elseif (!empty($this->request->params['controller'])) {
$options['url']['controller'] = Inflector::underscore($this->request->params['controller']);
}
}
if (empty($options['action'])) {
$options['action'] = $this->request['action'];
$options['action'] = $this->request->params['action'];
}

$actionDefaults = array(
Expand Down Expand Up @@ -307,9 +307,9 @@ function create($model = null, $options = array()) {
$htmlAttributes = array_merge($options, $htmlAttributes);

$this->fields = array();
if (isset($this->request['_Token']) && !empty($this->request['_Token'])) {
if (isset($this->request->params['_Token']) && !empty($this->request->params['_Token'])) {
$append .= $this->hidden('_Token.key', array(
'value' => $this->request['_Token']['key'], 'id' => 'Token' . mt_rand())
'value' => $this->request->params['_Token']['key'], 'id' => 'Token' . mt_rand())
);
}

Expand Down

0 comments on commit e40ee25

Please sign in to comment.