some code outline filter optimizations
@@ -1246,21 +1246,18 @@ static void updateSidebarCode(Code* code)
updateEditor(code);
}
-static bool isFilterMatch(const char* buffer, const char* filter)
+static bool isFilterMatch(const char* buffer, s32 size, const char* filter)
{
- while(*buffer)
- {
- if(tolower(*buffer) == tolower(*filter))
+ while(size--)
+ if(tolower(*buffer++) == tolower(*filter))
filter++;
- buffer++;
- }
return *filter == 0;
}
-static void drawFilterMatch(Code *code, s32 x, s32 y, const char* orig, const char* filter)
+static void drawFilterMatch(Code *code, s32 x, s32 y, const char* orig, s32 size, const char* filter)
{
- while(*orig)
+ while(size--)
{
bool match = tolower(*orig) == tolower(*filter);
u8 color = match ? tic_color_orange : tic_color_white;
@@ -1292,20 +1289,13 @@ static void initSidebarMode(Code* code)
if(items)
{
- char buffer[STUDIO_TEXT_BUFFER_WIDTH];
for(const tic_outline_item *it = items, *end = items + size; it != end ; ++it)
{
if(code->state[it->pos - code->src].syntax == SyntaxType_COMMENT)
continue;
- {
- s32 len = MIN(it->size, sizeof(buffer) - 1);
- memcpy(buffer, it->pos, len);
- buffer[len] = '\0';
- }
-
const char* filter = code->popup.text;
- if(*filter && !isFilterMatch(buffer, filter))
+ if(*filter && !isFilterMatch(it->pos, it->size, filter))
continue;
s32 last = code->sidebar.size++;
@@ -1991,15 +1981,9 @@ static void drawSidebarBar(Code* code, s32 x, s32 y)
tic_api_rect(code->tic, rect.x - 1, rect.y + (code->sidebar.index - code->sidebar.scroll) * STUDIO_TEXT_HEIGHT,
rect.w + 1, TIC_FONT_HEIGHT + 2, tic_color_red);
- char orig[STUDIO_TEXT_BUFFER_WIDTH];
for(const tic_outline_item* ptr = code->sidebar.items, *end = ptr + code->sidebar.size;
- ptr < end; ptr++, y += STUDIO_TEXT_HEIGHT)
- {
- s32 len = MIN(ptr->size, sizeof(orig) - 1);
- memcpy(orig, ptr->pos, len);
- orig[len] = '\0';
- drawFilterMatch(code, x, y, orig, filter);
- }
+ ptr != end; ptr++, y += STUDIO_TEXT_HEIGHT)
+ drawFilterMatch(code, x, y, ptr->pos, ptr->size, filter);
}
else
{
