<commit_before>/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#include "LayoutAnimationKeyFrameManager.h"

#include <algorithm>
#include <chrono>

#include <react/debug/flags.h>
#include <react/debug/react_native_assert.h>

#include <react/renderer/componentregistry/ComponentDescriptorFactory.h>
#include <react/renderer/components/root/RootShadowNode.h>
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/ComponentDescriptor.h>
#include <react/renderer/core/LayoutMetrics.h>
#include <react/renderer/core/LayoutableShadowNode.h>
#include <react/renderer/core/Props.h>
#include <react/renderer/core/RawValue.h>
#include <react/renderer/mounting/MountingCoordinator.h>
#include <react/renderer/mounting/ShadowViewMutation.h>

#include <react/renderer/mounting/Differentiator.h>
#include <react/renderer/mounting/ShadowTreeRevision.h>
#include <react/renderer/mounting/ShadowView.h>

#include <glog/logging.h>

namespace facebook {
namespace react {

#ifdef LAYOUT_ANIMATION_VERBOSE_LOGGING
static std::string GetMutationInstructionString(
    ShadowViewMutation const &mutation) {
  bool mutationIsRemove = mutation.type == ShadowViewMutation::Type::Remove;
  bool mutationIsInsert = mutation.type == ShadowViewMutation::Type::Insert;
  bool mutationIsDelete = mutation.type == ShadowViewMutation::Type::Delete;
  bool mutationIsCreate = mutation.type == ShadowViewMutation::Type::Create;
  std::string mutationType =
      (mutationIsRemove
           ? "REMOVE"
           : (mutationIsInsert
                  ? "INSERT"
                  : (mutationIsDelete
                         ? "DELETE"
                         : (mutationIsCreate ? "CREATE" : "UPDATE"))));
  return mutationType + " [" +
      std::to_string(
             mutationIsInsert || mutationIsCreate
                 ? mutation.newChildShadowView.tag
                 : mutation.oldChildShadowView.tag) +
      "]->[" + std::to_string(mutation.parentShadowView.tag) + "] @" +
      std::to_string(mutation.index);
}

void PrintMutationInstruction(
    std::string message,
    ShadowViewMutation const &mutation) {
  LOG(ERROR) << message
             << " Mutation: " << GetMutationInstructionString(mutation);
}
void PrintMutationInstructionRelative(
    std::string message,<commit_msg>Print ShadowView hash when displaying instructions<commit_after>/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

#include "LayoutAnimationKeyFrameManager.h"

#include <algorithm>
#include <chrono>

#include <react/debug/flags.h>
#include <react/debug/react_native_assert.h>

#include <react/renderer/componentregistry/ComponentDescriptorFactory.h>
#include <react/renderer/components/root/RootShadowNode.h>
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/ComponentDescriptor.h>
#include <react/renderer/core/LayoutMetrics.h>
#include <react/renderer/core/LayoutableShadowNode.h>
#include <react/renderer/core/Props.h>
#include <react/renderer/core/RawValue.h>
#include <react/renderer/mounting/MountingCoordinator.h>
#include <react/renderer/mounting/ShadowViewMutation.h>

#include <react/renderer/mounting/Differentiator.h>
#include <react/renderer/mounting/ShadowTreeRevision.h>
#include <react/renderer/mounting/ShadowView.h>

#include <glog/logging.h>

namespace facebook {
namespace react {

#ifdef LAYOUT_ANIMATION_VERBOSE_LOGGING
static std::string GetMutationInstructionString(
    ShadowViewMutation const &mutation) {
  bool mutationIsRemove = mutation.type == ShadowViewMutation::Type::Remove;
  bool mutationIsInsert = mutation.type == ShadowViewMutation::Type::Insert;
  bool mutationIsDelete = mutation.type == ShadowViewMutation::Type::Delete;
  bool mutationIsCreate = mutation.type == ShadowViewMutation::Type::Create;
  std::string mutationType =
      (mutationIsRemove
           ? "REMOVE"
           : (mutationIsInsert
                  ? "INSERT"
                  : (mutationIsDelete
                         ? "DELETE"
                         : (mutationIsCreate ? "CREATE" : "UPDATE"))));
  return mutationType + " [" +
      std::to_string(
             mutationIsInsert || mutationIsCreate
                 ? mutation.newChildShadowView.tag
                 : mutation.oldChildShadowView.tag) +
      "]->[" + std::to_string(mutation.parentShadowView.tag) + "] @" +
      std::to_string(mutation.index);
}

void PrintMutationInstruction(
    std::string message,
    ShadowViewMutation const &mutation) {
  [&](std::ostream &stream) -> std::ostream & {
    stream << message
           << " Mutation: " << GetMutationInstructionString(mutation);
    if (mutation.oldChildShadowView.tag != 0) {
      stream << " old hash: ##"
             << std::hash<ShadowView>{}(mutation.oldChildShadowView);
    }
    if (mutation.newChildShadowView.tag != 0) {
      stream << " new hash: ##"
             << std::hash<ShadowView>{}(mutation.newChildShadowView);
    }
    return stream;
  }(LOG(ERROR));
}
void PrintMutationInstructionRelative(
    std::string message,
{'fraction_non_alphanumeric': 0.1201206864039223, 'fraction_numerical': 0.0003771450122572129, 'mean_word_length': 3.830601092896175, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6204254', 'n_tokens_mistral': 1573, 'n_tokens_neox': 1558, 'n_words': 286}