<commit_before>import t from 'tcomb';
import isReactComponent from '../isReactComponent';
import debug from 'debug';

const log = debug('revenge:@pure');

function shallowEqual(objA, objB, section, component) {
  if (objA === objB) {
    return true;
  }
  const displayName = component.constructor.name;
  const rootNodeID = component._reactInternalInstance._rootNodeID;
  let key;
  // Test for A's keys different from B.
  for (key in objA) {
    if (objA.hasOwnProperty(key) &&
        (!objB.hasOwnProperty(key) || objA[key] !== objB[key])) {
      if (process.env.NODE_ENV !== 'production') {
        log(`component ${displayName} with rootNodeID ${rootNodeID} will re-render since ${section} key ${key} is changed from `, objA[key], ' to ', objB[key]);
      }
      return false;
    }
  }
  // Test for B's keys missing from A.
  for (key in objB) {
    if (objB.hasOwnProperty(key) && !objA.hasOwnProperty(key)) {
      if (process.env.NODE_ENV !== 'production') {
        log(`component ${displayName} with rootNodeID ${rootNodeID} will re-render since ${section} key ${key} with value `, objB[key], 'is new');
      }
      return false;
    }
  }
  return true;
}

export default function pure(Component) {<commit_msg>handle more gracefully a nully objA in shallowEqual<commit_after>import t from 'tcomb';
import isReactComponent from '../isReactComponent';
import debug from 'debug';

const log = debug('revenge:@pure');

function shallowEqual(objA, objB, section, component) {
  if (objA === objB) {
    return true;
  }

  const displayName = component.constructor.name;
  const rootNodeID = component._reactInternalInstance._rootNodeID;

  if (!objA || typeof objA !== 'object') {
    // the opposite should never happen here, since we are using this as
    // `shallowEqual(prevProps, nextProps)` or `shallowEqual(prevState, nextState)`
    if (process.env.NODE_ENV !== 'production') {
      log(`component ${displayName} with rootNodeID ${rootNodeID} will re-render since object has no previous value`);
    }
    return false;
  }

  let key;
  // Test for A's keys different from B.
  for (key in objA) {
    if (objA.hasOwnProperty(key) &&
        (!objB.hasOwnProperty(key) || objA[key] !== objB[key])) {
      if (process.env.NODE_ENV !== 'production') {
        log(`component ${displayName} with rootNodeID ${rootNodeID} will re-render since ${section} key ${key} is changed from `, objA[key], ' to ', objB[key]);
      }
      return false;
    }
  }
  // Test for B's keys missing from A.
  for (key in objB) {
    if (objB.hasOwnProperty(key) && !objA.hasOwnProperty(key)) {
      if (process.env.NODE_ENV !== 'production') {
        log(`component ${displayName} with rootNodeID ${rootNodeID} will re-render since ${section} key ${key} with value `, objB[key], 'is new');
      }
      return false;
    }
  }
  return true;
}

export default function pure(Component) {
{'fraction_non_alphanumeric': 0.14108313211452225, 'fraction_numerical': 0.0, 'mean_word_length': 3.496124031007752, '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': '1643728', 'n_tokens_mistral': 914, 'n_tokens_neox': 917, 'n_words': 271}