<commit_before>import { AttributeTypesAction, AttributeTypesActions, setAttributeTypes, UpdateAttributeTypeAction } from "./attributeTypes.actions"
import { AttributeTypes } from "../../../../codeCharta.model"
const clone = require("rfdc")()

export function attributeTypes(state: AttributeTypes = setAttributeTypes().payload, action: AttributeTypesAction): AttributeTypes {
	switch (action.type) {
		case AttributeTypesActions.SET_ATTRIBUTE_TYPES:
			return clone(action.payload)
		case AttributeTypesActions.UPDATE_ATTRIBUTE_TYPE:
			return updateAttributeType(state, action)
		default:
			return state
	}
}

function updateAttributeType(state: AttributeTypes, action: UpdateAttributeTypeAction) {
	const copy = clone(state)
	if (copy[action.payload.category]) {
		copy[action.payload.category][action.payload.name] = action.payload.type
	}
	return copy
}<commit_msg>Refactor use shallow clone instead of deep clone<commit_after>import { AttributeTypesAction, AttributeTypesActions, setAttributeTypes, UpdateAttributeTypeAction } from "./attributeTypes.actions"
import { AttributeTypes } from "../../../../codeCharta.model"
const clone = require("rfdc")()

export function attributeTypes(state: AttributeTypes = setAttributeTypes().payload, action: AttributeTypesAction): AttributeTypes {
	switch (action.type) {
		case AttributeTypesActions.SET_ATTRIBUTE_TYPES:
			return clone(action.payload)
		case AttributeTypesActions.UPDATE_ATTRIBUTE_TYPE:
			return updateAttributeType(state, action)
		default:
			return state
	}
}

function updateAttributeType(state: AttributeTypes, action: UpdateAttributeTypeAction): AttributeTypes {
	return { ...state, [action.payload.category]: { ...state[action.payload.category], [action.payload.name]: action.payload.type } }
}
{'fraction_non_alphanumeric': 0.11054421768707483, 'fraction_numerical': 0.0, 'mean_word_length': 6.204081632653061, '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': '6821417', 'n_tokens_mistral': 479, 'n_tokens_neox': 466, 'n_words': 105}