X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Fstacker%2Ffile%2Fclass_BaseFileStack.php;h=30f20f9c93fcc9c39e8564bfc6844155d979e65c;hb=6e91754d589773df8bd3746008dd782133a48674;hp=a5fba08d12e2fb59e9512e25d2e302099c08ee70;hpb=c3da44af864dac278a45df35d39f5cd75ced35a2;p=core.git diff --git a/framework/main/classes/stacker/file/class_BaseFileStack.php b/framework/main/classes/stacker/file/class_BaseFileStack.php index a5fba08d..30f20f9c 100644 --- a/framework/main/classes/stacker/file/class_BaseFileStack.php +++ b/framework/main/classes/stacker/file/class_BaseFileStack.php @@ -50,6 +50,11 @@ abstract class BaseFileStack extends BaseStacker implements StackableFile { // Exception codes const EXCEPTION_BAD_MAGIC = 0xe100; + /** + * Minimum block length + */ + private static $minimumBlockLength = 0; + /** * Protected constructor * @@ -510,19 +515,22 @@ abstract class BaseFileStack extends BaseStacker implements StackableFile { * @return $length Minimum length for one entry/block */ public function calculateMinimumBlockLength () { - // Calulcate it + // Is the value "cached"? /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-FILE-STACK: CALLED!'); - $length = - // Length of entry group - BaseBinaryFile::LENGTH_GROUP + strlen(chr(BaseBinaryFile::SEPARATOR_GROUP_HASH)) + - // Hash + value - self::getHashLength() + strlen(chr(BaseBinaryFile::SEPARATOR_HASH_VALUE)) + 1 + - // Final separator - strlen(chr(BaseBinaryFile::SEPARATOR_ENTRIES)); + if (self::$minimumBlockLength == 0) { + // Calulcate it + self::$minimumBlockLength = + // Length of entry group + BaseBinaryFile::LENGTH_GROUP + strlen(chr(BaseBinaryFile::SEPARATOR_GROUP_HASH)) + + // Hash + value + self::getHashLength() + strlen(chr(BaseBinaryFile::SEPARATOR_HASH_VALUE)) + 1 + + // Final separator + strlen(chr(BaseBinaryFile::SEPARATOR_ENTRIES)); + } // Return it - /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: length=%d - EXIT!', $length)); - return $length; + /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-FILE-STACK: self::minimumBlockLength=%d - EXIT!', self::$minimumBlockLength)); + return self::$minimumBlockLength; } /**