mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-26 07:04:27 +00:00
Optimization: skip call to 'has' method when possible
This commit is contained in:
parent
330fda6715
commit
d6127e6821
@ -23,7 +23,7 @@ class Env extends Hash
|
||||
|
||||
public function get(string $key)
|
||||
{
|
||||
if ($this->has($key)) {
|
||||
if (array_key_exists($key, $this->data)) {
|
||||
return $this->data[$key];
|
||||
} elseif ($this->parent) {
|
||||
return $this->parent->get($key);
|
||||
|
@ -5,7 +5,7 @@ class Hash extends Collection
|
||||
{
|
||||
public function get(string $key)
|
||||
{
|
||||
if ($this->has($key)) {
|
||||
if (array_key_exists($key, $this->data)) {
|
||||
return $this->data[$key];
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ class MList extends Seq
|
||||
{
|
||||
public function get(int $index)
|
||||
{
|
||||
if ($this->has($index)) {
|
||||
if (array_key_exists($index, $this->data)) {
|
||||
return $this->data[$index];
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ class Vector extends Seq
|
||||
{
|
||||
public function get(int $index)
|
||||
{
|
||||
if ($this->has($index)) {
|
||||
if (array_key_exists($index, $this->data)) {
|
||||
return $this->data[$index];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user