<commit_before>/**
 * @file
 * @brief TODO
 *
 * @date Aug 28, 2012
 * @author <NAME>
 */

#include <debug/symbol.h>
#include <types.h>

extern const struct symbol __symbol_table[];
extern const size_t __symbol_table_size;

const struct symbol *symbol_lookup(void *addr) {
	const struct symbol *last = NULL;

	/* Plain search. */
	for (const struct symbol *s = __symbol_table;
			s < __symbol_table + __symbol_table_size; ++s) {

		if (s->addr > addr) {
			break;
		}
		last = s;
	}

	return last;
}
<commit_msg>symbol_lookup is using binary search now<commit_after>/**
 * @file
 * @brief TODO
 *
 * @date Aug 28, 2012
 * @author <NAME>
 */

#include <debug/symbol.h>
#include <types.h>

extern const struct symbol __symbol_table[];
extern const size_t __symbol_table_size;

const struct symbol *symbol_lookup(void *addr) {
	size_t l = 0, r = __symbol_table_size, m;

	/* Binary search */
	while (l < r) {
		m = (l + r + 1) / 2;
		if (__symbol_table[m].addr <= addr) {
			l = m;
		} else {
			r = m - 1;
		}
	}

	if (l == __symbol_table_size) {
		return NULL;
	} else {
		return &__symbol_table[l];
	}
}

{'fraction_non_alphanumeric': 0.14402173913043478, 'fraction_numerical': 0.014492753623188406, 'mean_word_length': 3.31640625, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 11, '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': '2449732', 'n_tokens_mistral': 459, 'n_tokens_neox': 416, 'n_words': 119}