Skip to main content
Code Review

Return to Answer

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

I thought about this again. My comments are still valid, so including it in a php file including it in a php file is the cheapest way to get the array into your system and without a shared memory you will not reduce the total memory usage.

But maybe you can optimize it at an higher level of abstraction. Assuming that you always only need some countries/settings/localization in your loaded page and never all, you could split this array into multiple files.

<?php
...
function countryCodeToName($key)
{
 if (isset($this->countries[$key])) return $this->countries[$key];
 $firstCharacter=$key[0]
 include "country_".$firstCharacter.".php"; //similar to your file above
 $this->countries=$this->countries + $cty_arr;
 //some handling if still missing 
 //and return ...
}

I thought about this again. My comments are still valid, so including it in a php file is the cheapest way to get the array into your system and without a shared memory you will not reduce the total memory usage.

But maybe you can optimize it at an higher level of abstraction. Assuming that you always only need some countries/settings/localization in your loaded page and never all, you could split this array into multiple files.

<?php
...
function countryCodeToName($key)
{
 if (isset($this->countries[$key])) return $this->countries[$key];
 $firstCharacter=$key[0]
 include "country_".$firstCharacter.".php"; //similar to your file above
 $this->countries=$this->countries + $cty_arr;
 //some handling if still missing 
 //and return ...
}

I thought about this again. My comments are still valid, so including it in a php file is the cheapest way to get the array into your system and without a shared memory you will not reduce the total memory usage.

But maybe you can optimize it at an higher level of abstraction. Assuming that you always only need some countries/settings/localization in your loaded page and never all, you could split this array into multiple files.

<?php
...
function countryCodeToName($key)
{
 if (isset($this->countries[$key])) return $this->countries[$key];
 $firstCharacter=$key[0]
 include "country_".$firstCharacter.".php"; //similar to your file above
 $this->countries=$this->countries + $cty_arr;
 //some handling if still missing 
 //and return ...
}
Source Link
mheinzerling
  • 2.7k
  • 15
  • 17

I thought about this again. My comments are still valid, so including it in a php file is the cheapest way to get the array into your system and without a shared memory you will not reduce the total memory usage.

But maybe you can optimize it at an higher level of abstraction. Assuming that you always only need some countries/settings/localization in your loaded page and never all, you could split this array into multiple files.

<?php
...
function countryCodeToName($key)
{
 if (isset($this->countries[$key])) return $this->countries[$key];
 $firstCharacter=$key[0]
 include "country_".$firstCharacter.".php"; //similar to your file above
 $this->countries=$this->countries + $cty_arr;
 //some handling if still missing 
 //and return ...
}
lang-php

AltStyle によって変換されたページ (->オリジナル) /