fixed binary search impossible to find'

master
Allen Webster 2016-10-29 15:51:59 -04:00
parent 6c0015f1ed
commit 9de2633f51
2 changed files with 5 additions and 1 deletions

View File

@ -217,7 +217,7 @@ OPEN_FILE_HOOK_SIG(my_file_settings){
buffer_set_setting(app, &buffer, BufferSetting_WrapPosition, default_wrap_width); buffer_set_setting(app, &buffer, BufferSetting_WrapPosition, default_wrap_width);
buffer_set_setting(app, &buffer, BufferSetting_MapID, (treat_as_code)?((int32_t)my_code_map):((int32_t)mapid_file)); buffer_set_setting(app, &buffer, BufferSetting_MapID, (treat_as_code)?((int32_t)my_code_map):((int32_t)mapid_file));
if (treat_as_code && enable_code_wrapping && buffer.size < (1 << 20)){ if (treat_as_code && enable_code_wrapping && buffer.size < (1 << 18)){
// NOTE(allen|a4.0.12): There is a little bit of grossness going on here. // NOTE(allen|a4.0.12): There is a little bit of grossness going on here.
// If we set BufferSetting_Lex to true, it will launch a lexing job. // If we set BufferSetting_Lex to true, it will launch a lexing job.
// If a lexing job is active when we set BufferSetting_VirtualWhitespace on // If a lexing job is active when we set BufferSetting_VirtualWhitespace on

View File

@ -599,6 +599,10 @@ binary_search(i32 *array, i32 value, i32 l_bound, i32 u_bound){
i32 start = l_bound, end = u_bound; i32 start = l_bound, end = u_bound;
i32 i = 0; i32 i = 0;
if (value < 0){
value = 0;
}
for (;;){ for (;;){
i = (start + end) >> 1; i = (start + end) >> 1;
if (array[i] < value){ if (array[i] < value){