<commit_before>// Copyright (c) 1999 <NAME> (<EMAIL>)
// Portions Copyright (c) 1999 Network Associates, Inc.

package org.xbill.DNS;

import java.util.*;

/**
 * DNS Name Compression object.
 * @see Name
 *
 * @author <NAME>
 */

class Compression {

private Map h;

/**
 * Creates a new Compression object.
 */
public
Compression() {
	h = new HashMap();
}

/** Adds a compression entry mapping a name to a position.  */
public void
add(int pos, Name name) {
	h.put (name, new Integer(pos));
}

/**
 * Retrieves the position of the given name, if it has been previously
 * included in the message.
 */
public int
get(Name name) {
	Integer I = (Integer) h.get(name);
	return (I == null) ? (-1) : I.intValue();
}

}<commit_msg>Don't use a HashMap, use a simple inline hash table that requires far fewer allocations.<commit_after>// Copyright (c) 1999 <NAME> (<EMAIL>)
// Portions Copyright (c) 1999 Network Associates, Inc.

package org.xbill.DNS;

import java.util.*;

/**
 * DNS Name Compression object.
 * @see Name
 *
 * @author <NAME>
 */

class Compression {

private class Entry {
	Name name;
	int pos;
	Entry next;
}

private static final int TABLE_SIZE = 17;

private Entry [] table;

/**
 * Creates a new Compression object.
 */
public
Compression() {
	table = new Entry[TABLE_SIZE];
}

/** Adds a compression entry mapping a name to a position.  */
public void
add(int pos, Name name) {
	int row = (name.hashCode() & 0x7FFFFFFF) % TABLE_SIZE;
	Entry entry = new Entry();
	entry.name = name;
	entry.pos = pos;
	entry.next = table[row];
	table[row] = entry;
}

/**
 * Retrieves the position of the given name, if it has been previously
 * included in the message.
 */
public int
get(Name name) {
	int row = (name.hashCode() & 0x7FFFFFFF) % TABLE_SIZE;
	for (Entry entry = table[row]; entry != null; entry = entry.next) {
		if (entry.name.equals(name))
			return (entry.pos);
	}
	return (-1);
}

}
{'fraction_non_alphanumeric': 0.1402310924369748, 'fraction_numerical': 0.012605042016806723, 'mean_word_length': 3.4823529411764707, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '7295608', 'n_tokens_mistral': 671, 'n_tokens_neox': 637, 'n_words': 230}