<commit_before>/* ************************************************************************ */
/*																			*/
/*	Neko VM source															*/
/*  (c)2005 <NAME>												*/
/*																			*/
/* ************************************************************************ */
#include <string.h>
#include "objtable.h"

objtable otable_empty() {
	objtable t2 = (objtable)alloc(sizeof(objtable));
	t2->count = 0;
	t2->cells = NULL;
	return t2;
}

int otable_remove( objtable t, field id ) {
	int min = 0;
	int max = t->count;
	int mid;
	field cid;
	cell *c = t->cells;
	while( min < max ) {
		mid = (min + max) >> 1;
		cid = c[mid].id;
		if( cid < id )
			max = mid;
		else if( cid > id )
			min = mid;
		else {
			t->count--;
			while( mid < t->count ) {
				c[mid] = c[mid+1];
				mid++;
			}
			return 1;
		}
	}
	return 0;
}

void otable_optimize( objtable t ) {
	int max = t->count;
	int i;
	int cur = 0;
	cell *c = t->cells;
	for(i=0;i<max;i++) {
		value v = c[i].v;
		if( v != val_null )
			c[cur++] = c[i];
	}
	t->count = cur;
}

void otable_replace( objtable t, field id, value data ) {
	int min = 0;
	int max = t->count;
	int mid;
	field cid;
	cell *c = t->cells;
	while( min < max ) {
		mid = (min + max) >> 1;
		cid = c[mid].id;
		if( cid < id )
			max = mid;
		else if( cid > id )
			min = mid;
		else {
			c[mid].v = data;
			return;
		}
	}
	c = (cell*)alloc(sizeof(cell)*(t->count+1));
	min = 0;
	while( min < mid ) {
		c[min] = t->cells[min];
		min++;
	}
	c[mid].id = id;
	c[mid].v = data;
	while( min < t->count ) {
		c[min+1] = t->cells[min];
		min++;
	}
	t->cells = c;
	t->count++;
}<commit_msg>initialized mid (for first replace).<commit_after>/* ************************************************************************ */
/*																			*/
/*	Neko VM source															*/
/*  (c)2005 <NAME>												*/
/*																			*/
/* ************************************************************************ */
#include <string.h>
#include "objtable.h"

objtable otable_empty() {
	objtable t2 = (objtable)alloc(sizeof(objtable));
	t2->count = 0;
	t2->cells = NULL;
	return t2;
}

int otable_remove( objtable t, field id ) {
	int min = 0;
	int max = t->count;
	int mid;
	field cid;
	cell *c = t->cells;
	while( min < max ) {
		mid = (min + max) >> 1;
		cid = c[mid].id;
		if( cid < id )
			max = mid;
		else if( cid > id )
			min = mid;
		else {
			t->count--;
			while( mid < t->count ) {
				c[mid] = c[mid+1];
				mid++;
			}
			return 1;
		}
	}
	return 0;
}

void otable_optimize( objtable t ) {
	int max = t->count;
	int i;
	int cur = 0;
	cell *c = t->cells;
	for(i=0;i<max;i++) {
		value v = c[i].v;
		if( v != val_null )
			c[cur++] = c[i];
	}
	t->count = cur;
}

void otable_replace( objtable t, field id, value data ) {
	int min = 0;
	int max = t->count;
	int mid = 0;
	field cid;
	cell *c = t->cells;
	while( min < max ) {
		mid = (min + max) >> 1;
		cid = c[mid].id;
		if( cid < id )
			max = mid;
		else if( cid > id )
			min = mid;
		else {
			c[mid].v = data;
			return;
		}
	}
	c = (cell*)alloc(sizeof(cell)*(t->count+1));
	min = 0;
	while( min < mid ) {
		c[min] = t->cells[min];
		min++;
	}
	c[mid].id = id;
	c[mid].v = data;
	while( min < t->count ) {
		c[min+1] = t->cells[min];
		min++;
	}
	t->cells = c;
	t->count++;
}
{'fraction_non_alphanumeric': 0.27419847328244273, 'fraction_numerical': 0.013129770992366412, 'mean_word_length': 2.391304347826087, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 53, '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': '7268693', 'n_tokens_mistral': 1604, 'n_tokens_neox': 1356, 'n_words': 337}