<commit_before>package matcher

import (
	"fmt"
	"regexp"
	"strings"
)

type tree struct {
	root          *node
	cfg           *Config
	searchHistory []string
}

func (t *tree) ParamChar() byte {
	return t.cfg.ParamChar
}

func (t *tree) WildcardChar() byte {
	return t.cfg.WildcardChar
}

func (t *tree) MainSeparators() string {
	if len(t.cfg.Separators) > 0 {
		return string(t.cfg.Separators[0])
	}

	return ""
}

func (t *tree) OptionalSeparators() string {
	if len(t.cfg.Separators) > 1 {
		return t.cfg.Separators[1:]
	}

	return ""
}

func (t *tree) Separators() string {
	return t.cfg.Separators
}

func (t *tree) AllChars() string {
	return string([]byte{t.ParamChar(), t.WildcardChar()})
}

func (t *tree) setValue(n *node, value interface{}, tags Tags) GetSetter {
	if t.cfg.New != nil {
		if n.GetSetter == nil {
			n.GetSetter = t.cfg.New()
		}
	}

	if n.GetSetter != nil {
		n.GetSetter.Set(value, tags)
	}

	return n.GetSetter
}

func newTree(cfg *Config) *tree {
	return &tree{
		root: &node{},
		cfg:  cfg,
	}
}

func (t *tree) getValue(n *node, tags Tags) interface{} {
	if n.GetSetter == nil {
		return nil
	}

	return n.GetSetter.Get(tags)
}

func (t *tree) isLeaf(n *node, tags Tags) bool {
	return t.getValue(n, tags) != nil
}

func (tree *tree) findNode(c Context, path string, tags Tags) (out *node) {
	n := tree.root
	search := path<commit_msg>Cache separators in tree<commit_after>package matcher

import (
	"fmt"
	"regexp"
	"strings"
)

type tree struct {
	root          *node
	cfg           *Config
	searchHistory []string

	mainSep, optsSep string
	allChars         string
}

func (t *tree) ParamChar() byte {
	return t.cfg.ParamChar
}

func (t *tree) WildcardChar() byte {
	return t.cfg.WildcardChar
}

func (t *tree) MainSeparators() string {
	return t.mainSep
}

func (t *tree) OptionalSeparators() string {
	return t.optsSep
}

func (t *tree) Separators() string {
	return t.cfg.Separators
}

func (t *tree) AllChars() string {
	return t.allChars
}

func (t *tree) setValue(n *node, value interface{}, tags Tags) GetSetter {
	if t.cfg.New != nil {
		if n.GetSetter == nil {
			n.GetSetter = t.cfg.New()
		}
	}

	if n.GetSetter != nil {
		n.GetSetter.Set(value, tags)
	}

	return n.GetSetter
}

func newTree(cfg *Config) *tree {
	t := &tree{
		root: &node{},
		cfg:  cfg,
	}

	if len(t.cfg.Separators) == 0 {
		panicm("Separators should not be empty")
	}

	// Caching chars and separators
	t.allChars = string(t.ParamChar()) + string(t.WildcardChar())

	t.mainSep = string(t.cfg.Separators[0])
	if len(t.cfg.Separators) > 1 {
		t.optsSep = t.cfg.Separators[1:]
	}

	return t
}

func (t *tree) getValue(n *node, tags Tags) interface{} {
	if n.GetSetter == nil {
		return nil
	}

	return n.GetSetter.Get(tags)
}

func (t *tree) isLeaf(n *node, tags Tags) bool {
	return t.getValue(n, tags) != nil
}

func (tree *tree) findNode(c Context, path string, tags Tags) (out *node) {
	n := tree.root
	search := path
{'fraction_non_alphanumeric': 0.15010211027910142, 'fraction_numerical': 0.002722940776038121, 'mean_word_length': 3.3800298062593144, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '7186863', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1145, 'n_words': 308}