<commit_before>/**
 * @file
 */
#include "libbirch/Label.hpp"

libbirch::Label::Label() : Any(0) {
  //
}

libbirch::Label::Label(const Label& o) :
    Any(o) {
  auto& o1 = const_cast<Label&>(o);
  o1.lock.write();
  o1.memo.rehash();
  o1.lock.downgrade();
  memo.copy(o1.memo);
  o1.lock.unread();
}

libbirch::Any* libbirch::Label::mapGet(Any* o) {
  Any* prev = nullptr;
  Any* next = o;
  bool frozen = o->isFrozen();
  while (frozen && next) {
    prev = next;
    next = memo.get(prev);
    if (next) {
      frozen = next->isFrozen();
    }
  }
  if (!next) {
	  next = prev;
	}
  if (frozen) {
    assert(!next->isDestroyed());
    Any* cloned;
    if (false && next->isUnique()) {
      /* final-reference optimization: the pointer being updated is the final
       * remaining pointer to the object, rather than copying the object and
       * then destroying it, recycle the object to be the copy */
      cloned = next->recycle(this);
    } else {
      /* copy the object */
      cloned = next->copy(this);

      /* single-reference optimization: at the time of freezing, if there was
       * only one reference to the object, it need not be memoized, as there
       * are no other pointers to update to the copy */
      if (true || !next->isFrozenUnique()) {
        memo.put(next, cloned);
        thaw();
      }
    }
    next = cloned;
  }
  return next;
}

libbirch::Any* libbirch::Label::mapPull(Any* o) {
  Any* prev = nullptr;
  Any* next = o;
  bool frozen = o->isFrozen();
  while (frozen && next) {
    prev = next;
    next = memo.get(prev);
    if (next) {
      frozen = next->isFrozen();
    }
  }<commit_msg>Restored final-reference and single-reference optimizations (previously removed for debugging).<commit_after>/**
 * @file
 */
#include "libbirch/Label.hpp"

libbirch::Label::Label() : Any(0) {
  //
}

libbirch::Label::Label(const Label& o) :
    Any(o) {
  auto& o1 = const_cast<Label&>(o);
  o1.lock.write();
  o1.memo.rehash();
  o1.lock.downgrade();
  memo.copy(o1.memo);
  o1.lock.unread();
}

libbirch::Any* libbirch::Label::mapGet(Any* o) {
  Any* prev = nullptr;
  Any* next = o;
  bool frozen = o->isFrozen();
  while (frozen && next) {
    prev = next;
    next = memo.get(prev);
    if (next) {
      frozen = next->isFrozen();
    }
  }
  if (!next) {
	  next = prev;
	}
  if (frozen) {
    assert(!next->isDestroyed());
    Any* cloned;
    if (next->isUnique()) {
      /* final-reference optimization: the pointer being updated is the final
       * remaining pointer to the object, rather than copying the object and
       * then destroying it, recycle the object to be the copy */
      cloned = next->recycle(this);
    } else {
      /* copy the object */
      cloned = next->copy(this);

      /* single-reference optimization: at the time of freezing, if there was
       * only one reference to the object, it need not be memoized, as there
       * are no other pointers to update to the copy */
      if (!next->isFrozenUnique()) {
        memo.put(next, cloned);
        thaw();
      }
    }
    next = cloned;
  }
  return next;
}

libbirch::Any* libbirch::Label::mapPull(Any* o) {
  Any* prev = nullptr;
  Any* next = o;
  bool frozen = o->isFrozen();
  while (frozen && next) {
    prev = next;
    next = memo.get(prev);
    if (next) {
      frozen = next->isFrozen();
    }
  }
{'fraction_non_alphanumeric': 0.1540983606557377, 'fraction_numerical': 0.004172876304023845, 'mean_word_length': 2.5931477516059958, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '6568059', 'n_tokens_mistral': 1204, 'n_tokens_neox': 1185, 'n_words': 318}