mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-01 20:19:42 +08:00
Fixes #11950: Improve BaseArrayHelper::keyExists speed
This commit is contained in:
committed by
Alexander Makarov
parent
466fc9db32
commit
c99acb6182
@ -4,10 +4,10 @@ Yii Framework 2 Change Log
|
|||||||
2.0.10 under development
|
2.0.10 under development
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
- Bug #11949: Fixed `ActiveField::end` generates close tag when it's `option['tag']` is null (egorio)
|
|
||||||
- Bug #11912: Fixed PostgreSQL Schema to support negative default values for integer/float/decimal columns (nsknewbie)
|
- Bug #11912: Fixed PostgreSQL Schema to support negative default values for integer/float/decimal columns (nsknewbie)
|
||||||
- Bug #11947: Fixed `gridData` initialization in `yii.gridView.js` (pavlm)
|
- Bug #11947: Fixed `gridData` initialization in `yii.gridView.js` (pavlm)
|
||||||
|
- Bug #11949: Fixed `ActiveField::end` generates close tag when it's `option['tag']` is null (egorio)
|
||||||
|
- Enh #11950: Improve BaseArrayHelper::keyExists speed (egorio)
|
||||||
|
|
||||||
2.0.9 July 11, 2016
|
2.0.9 July 11, 2016
|
||||||
-------------------
|
-------------------
|
||||||
|
|||||||
@ -486,7 +486,9 @@ class BaseArrayHelper
|
|||||||
public static function keyExists($key, $array, $caseSensitive = true)
|
public static function keyExists($key, $array, $caseSensitive = true)
|
||||||
{
|
{
|
||||||
if ($caseSensitive) {
|
if ($caseSensitive) {
|
||||||
return array_key_exists($key, $array);
|
// Function `isset` checks key faster but skips `null`, `array_key_exists` handles this case
|
||||||
|
// http://php.net/manual/en/function.array-key-exists.php#107786
|
||||||
|
return isset($array[$key]) || array_key_exists($key, $array);
|
||||||
} else {
|
} else {
|
||||||
foreach (array_keys($array) as $k) {
|
foreach (array_keys($array) as $k) {
|
||||||
if (strcasecmp($key, $k) === 0) {
|
if (strcasecmp($key, $k) === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user