<commit_before><?php
namespace TheSeer\phpDox\Generator {

    use TheSeer\fDOM\fDOMElement;
    use TheSeer\fDOM\fDOMDocument;

    abstract class AbstractEntry {

        /**
         * @var fDOMElement
         */
        private $node;

        public function __construct(fDOMElement $node) {
            $this->node = $node;
        }

        protected function getNode() {
            return $this->node;
        }

        protected function loadDocument($dir) {
            $path = $dir . '/' . $this->getNode()->getAttribute('xml');
            $classDom = new fDOMDocument();
            $classDom->load($path);
            $classDom->registerNamespace('phpdox', 'http://xml.phpdox.de/src#');
            return $classDom;
        }
    }

}<commit_msg>Do not load same DOM multiple times<commit_after><?php
namespace TheSeer\phpDox\Generator {

    use TheSeer\fDOM\fDOMElement;
    use TheSeer\fDOM\fDOMDocument;

    abstract class AbstractEntry {

        /**
         * @var fDOMElement
         */
        private $node;

        private $dom = array();

        public function __construct(fDOMElement $node) {
            $this->node = $node;
        }

        protected function getNode() {
            return $this->node;
        }

        protected function loadDocument($dir) {
            $path = $dir . '/' . $this->getNode()->getAttribute('xml');
            if (!isset($this->dom[$path])) {
                $classDom = new fDOMDocument();
                $classDom->load($path);
                $classDom->registerNamespace('phpdox', 'http://xml.phpdox.de/src#');
                $this->dom[$path] = $classDom;
            }
            return $this->dom[$path];
        }
    }

}
{'fraction_non_alphanumeric': 0.13793103448275862, 'fraction_numerical': 0.0, 'mean_word_length': 1.7702265372168284, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4997952', 'n_tokens_mistral': 503, 'n_tokens_neox': 484, 'n_words': 91}