<commit_before>import React from "react";

import './KifuTreeNode.css';

export default class KifuTreeNode extends React.Component {
  shouldComponentUpdate(nextProps) {
    // if (this.props.pathArray.length <= 1) {
    //   console.log(this.props.pathArray);
    //   console.log('currentPath', nextProps.currentPath !== this.props.currentPath);
    //   console.log('kifuTreeNode', nextProps.kifuTreeNode !== this.props.kifuTreeNode);
    //   console.log('jumpMap', nextProps.jumpMapChanged);
    //   console.log('pathArray', JSON.stringify(nextProps.pathArray) !== JSON.stringify(this.props.pathArray));
    // }
    const shouldUpdate = nextProps.currentPath !== this.props.currentPath
      || nextProps.kifuTreeNode !== this.props.kifuTreeNode
      || nextProps.jumpMapChanged
      || JSON.stringify(nextProps.pathArray) !== JSON.stringify(this.props.pathArray);

    return shouldUpdate;
  }
  render() {
    const { kifuTreeNode, pathArray, currentPath, jumpMap, isJump, jumpMapChanged } = this.props;

    const hasComment = kifuTreeNode.comment;
    const path = JSON.stringify(pathArray);
    const isCurrent = path === currentPath
    const isBad = hasComment && kifuTreeNode.comment.startsWith('bad:');
    const isControllable = pathArray.length > 0 && !isJump;

    function renderChildren() {
      if (isJump) {
        return [];
      }
<commit_msg>Improve performance of rendering when current node is changed<commit_after>import React from "react";

import './KifuTreeNode.css';

function isSubPath(myPath, testPath) {
  if (testPath.length < myPath.length) {
    return false;
  }
  return testPath.substr(0, myPath.length - 1) === myPath.substr(0, myPath.length - 1);
}

export default class KifuTreeNode extends React.Component {
  shouldComponentUpdate(nextProps) {
    // if (this.props.pathArray.length <= 1) {
    //   console.log(this.props.pathArray);
    //   console.log('currentPath', nextProps.currentPath !== this.props.currentPath);
    //   console.log('kifuTreeNode', nextProps.kifuTreeNode !== this.props.kifuTreeNode);
    //   console.log('jumpMap', nextProps.jumpMapChanged);
    //   console.log('pathArray', JSON.stringify(nextProps.pathArray) !== JSON.stringify(this.props.pathArray));
    // }
    const nextPath = JSON.stringify(nextProps.pathArray);
    const prevPath = JSON.stringify(this.props.pathArray)
    const shouldUpdate = (nextProps.currentPath !== this.props.currentPath && (isSubPath(prevPath, this.props.currentPath) || isSubPath(nextPath, nextProps.currentPath)))
      || nextProps.kifuTreeNode !== this.props.kifuTreeNode
      || nextProps.jumpMapChanged
      || nextPath !== prevPath;

    return shouldUpdate;
  }
  render() {
    const { kifuTreeNode, pathArray, currentPath, jumpMap, isJump, jumpMapChanged } = this.props;

    const hasComment = kifuTreeNode.comment;
    const path = JSON.stringify(pathArray);
    const isCurrent = path === currentPath
    const isBad = hasComment && kifuTreeNode.comment.startsWith('bad:');
    const isControllable = pathArray.length > 0 && !isJump;

    function renderChildren() {
      if (isJump) {
        return [];
      }

{'fraction_non_alphanumeric': 0.13449920508744037, 'fraction_numerical': 0.0025437201907790143, 'mean_word_length': 3.7522658610271904, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, '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': '5919035', 'n_tokens_mistral': 982, 'n_tokens_neox': 964, 'n_words': 177}