<commit_before>'use strict'
const diff = require('./diff')
const INIT = 'new'
const UPDATE = 'update'
const REMOVE = 'remove'
const SWITCH = 'switch'

// move all this to struct fast...
exports.update = function updateState (target, travelTarget, subs, update, tree, stamp) {
  if ('val' in subs) {
    if (subs.val === true) {
      update(target, UPDATE, stamp, subs, tree)
    } else {
      const val = target.val
      if (val && typeof val === 'object' && val.isBase) {
        if (tree.$sid !== (val._sid || val.sid())) {
          tree.$sid = val._sid
          update(target, UPDATE, stamp, subs, tree)
        }
      } else if (tree.$sid) {
        delete tree.$sid
        update(target, UPDATE, stamp, subs, tree)
      }
    }
  }
  diff(travelTarget, subs, update, tree, stamp)
}

exports.create = function create (target, travelTarget, subs, update, tree, stamp) {
  if ('val' in subs) {
    const val = target.val
    if (val && typeof val === 'object' && val.isBase) {
      tree.$sid = (val._sid || val.sid())
    }
    update(target, INIT, stamp, subs, tree)
  }
  // this is def wrong
  diff(travelTarget, subs, update, tree, stamp)
}

exports.simpleUpdate = function simpleUpdate (target, subs, update, tree, stamp) {
  if ('val' in subs && subs.val === true) {
    update(target, UPDATE, stamp, subs, tree)
  }<commit_msg>lower mem usage for $sid field in tree<commit_after>'use strict'
const diff = require('./diff')
const INIT = 'new'
const UPDATE = 'update'
const REMOVE = 'remove'
const SWITCH = 'switch'

// move all this to struct fast...
exports.update = function updateState (target, travelTarget, subs, update, tree, stamp) {
  if ('val' in subs) {
    if (subs.val === true) {
      update(target, UPDATE, stamp, subs, tree)
    } else {
      const val = target.val
      if (val && typeof val === 'object' && val.isBase) {
        if (tree.$s !== (val._sid || val.sid())) {
          tree.$s = val._sid
          update(target, UPDATE, stamp, subs, tree)
        }
      } else if (tree.$s) {
        delete tree.$s
        update(target, UPDATE, stamp, subs, tree)
      }
    }
  }
  diff(travelTarget, subs, update, tree, stamp)
}

exports.create = function create (target, travelTarget, subs, update, tree, stamp) {
  if ('val' in subs) {
    const val = target.val
    if (val && typeof val === 'object' && val.isBase) {
      tree.$s = (val._sid || val.sid())
    }
    update(target, INIT, stamp, subs, tree)
  }
  // this is def wrong
  diff(travelTarget, subs, update, tree, stamp)
}

exports.simpleUpdate = function simpleUpdate (target, subs, update, tree, stamp) {
  if ('val' in subs && subs.val === true) {
    update(target, UPDATE, stamp, subs, tree)
  }
{'fraction_non_alphanumeric': 0.155637707948244, 'fraction_numerical': 0.0, 'mean_word_length': 2.768802228412256, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7350626', 'n_tokens_mistral': 889, 'n_tokens_neox': 861, 'n_words': 283}