Skip to content

Commit

Permalink
Using the method cache for the rest of the return statements in DboSo…
Browse files Browse the repository at this point in the history
…urce::name
  • Loading branch information
lorenzo committed Feb 23, 2010
1 parent 753721c commit 6ae54fd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cake/libs/model/datasources/dbo_source.php
Expand Up @@ -484,26 +484,26 @@ function name($data) {
}
return $data;
}
$cacheKey = crc32($data);
$cacheKey = crc32($this->startQuote.$data.$this->endQuote);
if (isset($this->methodCache[__FUNCTION__][$cacheKey])) {
return $this->methodCache[__FUNCTION__][$cacheKey];
}
$data = trim($data);
if (preg_match('/^[\w-]+(\.[\w-]+)*$/', $data)) { // string, string.string
if (strpos($data, '.') === false) { // string
return $this->startQuote . $data . $this->endQuote;
return $this->methodCache[__FUNCTION__][$cacheKey] = $this->startQuote . $data . $this->endQuote;
}
$items = explode('.', $data);
return $this->startQuote . implode($this->endQuote . '.' . $this->startQuote, $items) . $this->endQuote;
return $this->methodCache[__FUNCTION__][$cacheKey] = $this->startQuote . implode($this->endQuote . '.' . $this->startQuote, $items) . $this->endQuote;
}
if (preg_match('/^[\w-]+\.\*$/', $data)) { // string.*
return $this->startQuote . str_replace('.*', $this->endQuote . '.*', $data);
return $this->methodCache[__FUNCTION__][$cacheKey] = $this->startQuote . str_replace('.*', $this->endQuote . '.*', $data);
}
if (preg_match('/^([\w-]+)\((.*)\)$/', $data, $matches)) { // Functions
return $matches[1] . '(' . $this->name($matches[2]) . ')';
return $this->methodCache[__FUNCTION__][$cacheKey] = $matches[1] . '(' . $this->name($matches[2]) . ')';
}
if (preg_match('/^([\w-]+(\.[\w-]+|\(.*\))*)\s+' . preg_quote($this->alias) . '\s*([\w-]+)$/', $data, $matches)) {
return preg_replace('/\s{2,}/', ' ', $this->name($matches[1]) . ' ' . $this->alias . ' ' . $this->name($matches[3]));
return $this->methodCache[__FUNCTION__][$cacheKey] = preg_replace('/\s{2,}/', ' ', $this->name($matches[1]) . ' ' . $this->alias . ' ' . $this->name($matches[3]));
}
return $this->methodCache[__FUNCTION__][$cacheKey] = $data;
}
Expand Down

0 comments on commit 6ae54fd

Please sign in to comment.