diff --git a/CHANGELOG.md b/CHANGELOG.md index aacf2d7..43e3459 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ ## iGame VERSION_TAG - [RELEASE_DATE] ### Changed +- Some optimisation in list loading reducing the time needed more than 42% + +## iGame 2.4.4 - [2023-09-11] +### Changed - Speedup the slavesListAddTail(), almost 200% faster. This has an impact on the slaves list creation during the scan and the loading from the file. ### Fixed diff --git a/src/fsfuncs.c b/src/fsfuncs.c index f208b02..b69c478 100644 --- a/src/fsfuncs.c +++ b/src/fsfuncs.c @@ -176,11 +176,11 @@ BOOL get_filename(const char *title, const char *positive_text, const BOOL save_ void slavesListLoadFromCSV(char *filename) { - int lineBufSize = sizeof(char) * 1024; + int lineBufSize = sizeof(char) * 512; if (check_path_exists(filename)) { - const BPTR fpgames = Open((CONST_STRPTR) filename, MODE_OLDFILE); + FILE *fpgames = fopen(filename, "r"); if (fpgames) { char *lineBuf = AllocVec(lineBufSize, MEMF_CLEAR); @@ -188,10 +188,11 @@ void slavesListLoadFromCSV(char *filename) if((buf == NULL) || (lineBuf == NULL)) { msg_box((const char*)GetMBString(MSG_NotEnoughMemory)); + fclose(fpgames); return; } - while (FGets(fpgames, lineBuf, lineBufSize) != NULL) + while (fgets(lineBuf, lineBufSize, fpgames) != NULL) { slavesList *node = malloc(sizeof(slavesList)); if(node == NULL) @@ -282,7 +283,7 @@ void slavesListLoadFromCSV(char *filename) slavesListAddTail(node); } - Close(fpgames); + fclose(fpgames); FreeVec(lineBuf); } } diff --git a/src/funcs.c b/src/funcs.c index 9574644..070e064 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -308,7 +308,7 @@ static void populateGenresList(void) int cnt = 0; while (currPtr != NULL) { - DoMethod(app->LV_GenresList, MUIM_List_InsertSingle, currPtr->title, MUIV_List_Insert_Sorted); + DoMethod(app->LV_GenresList, MUIM_List_InsertSingle, currPtr->title, MUIV_List_Insert_Bottom); cnt++; currPtr = currPtr->next; @@ -323,6 +323,8 @@ static void populateGenresList(void) app->CY_PropertiesGenreContent[i++] = NULL; set(app->CY_PropertiesGenre, MUIA_Cycle_Entries, app->CY_PropertiesGenreContent); set(app->CY_AddGameGenre, MUIA_Cycle_Entries, app->CY_PropertiesGenreContent); + set(app->LV_GenresList, MUIA_List_Active, MUIV_List_Active_Top); + DoMethod(app->LV_GenresList, MUIM_List_Sort); set(app->LV_GenresList, MUIA_List_Quiet, FALSE); } @@ -360,7 +362,6 @@ void app_start(void) load_repos(DEFAULT_REPOS_FILE); apply_settings(); - if (current_settings->start_with_favorites) { filters.showGroup = GROUP_FAVOURITES; @@ -381,7 +382,7 @@ void app_start(void) if (!current_settings->hide_side_panel) { - populateGenresList(); + populateGenresList(); // This calls the filter_change() populateChipsetList(); } if (current_settings->hide_side_panel) @@ -682,9 +683,6 @@ static void showSlavesList(void) { if (currPtr->times_played < mostPlayedTimes) { - // DoMethod(app->LV_GamesList, - // MUIM_List_InsertSingle, currPtr->title, - // MUIV_List_Insert_Bottom); DoMethod(app->LV_GamesList, MUIM_NList_InsertSingle, currPtr, MUIV_NList_Insert_Bottom); @@ -692,9 +690,7 @@ static void showSlavesList(void) else { mostPlayedTimes = currPtr->times_played; - // DoMethod(app->LV_GamesList, - // MUIM_List_InsertSingle, currPtr->title, - // MUIV_List_Insert_Top); + DoMethod(app->LV_GamesList, MUIM_NList_InsertSingle, currPtr, MUIV_NList_Insert_Top); @@ -713,7 +709,7 @@ static void showSlavesList(void) DoMethod(app->LV_GamesList, MUIM_NList_InsertSingle, currPtr, - MUIV_NList_Insert_Sorted); + MUIV_NList_Insert_Bottom); cnt++; nextItem: @@ -721,6 +717,7 @@ static void showSlavesList(void) currPtr = currPtr->next; } + DoMethod(app->LV_GamesList, MUIM_NList_Sort); set(app->LV_GamesList, MUIA_NList_Quiet, FALSE); sprintf(buf, (const char *)GetMBString(MSG_TotalNumberOfGames), slavesListNodeCount(cnt)); @@ -1443,14 +1440,13 @@ void list_show_hidden(void) { set(app->LV_GenresList, MUIA_Disabled, TRUE); filters.showHiddenOnly = TRUE; - showSlavesList(); } else { set(app->LV_GenresList, MUIA_Disabled, FALSE); filters.showHiddenOnly = FALSE; - showSlavesList(); } + showSlavesList(); } void app_stop(void) @@ -1768,9 +1764,10 @@ void non_whdload_ok(void) set(app->LV_GamesList, MUIA_NList_Quiet, TRUE); DoMethod(app->LV_GamesList, MUIM_NList_InsertSingle, node, - MUIV_NList_Insert_Sorted); + MUIV_NList_Insert_Bottom); get(app->LV_GamesList, MUIA_NList_InsertPosition, &newpos); set(app->LV_GamesList, MUIA_NList_Active, newpos); + DoMethod(app->LV_GamesList, MUIM_NList_Sort); set(app->LV_GamesList, MUIA_NList_Quiet, FALSE); } diff --git a/src/iGameGUI.c b/src/iGameGUI.c index 785e79c..dfb50a5 100644 --- a/src/iGameGUI.c +++ b/src/iGameGUI.c @@ -191,30 +191,30 @@ HOOKPROTONHNO(CompareLI_TextFunc, LONG, struct NList_CompareMessage *ncm) if(ncm->sort_type == (LONG)MUIV_NList_SortType_None) { - result = (LONG) Stricmp(entry1->title, entry2->title); + result = (LONG) strcmp(entry1->title, entry2->title); return result; } if (column == 0) { if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask) - result = (LONG) Stricmp(entry2->title, entry1->title); + result = (LONG) strcmp(entry2->title, entry1->title); else - result = (LONG) Stricmp(entry1->title, entry2->title); + result = (LONG) strcmp(entry1->title, entry2->title); } else if (column == 1) { if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask) - result = (LONG) Stricmp(entry2->year, entry1->year); + result = (LONG) strcmp(entry2->year, entry1->year); else - result = (LONG) Stricmp(entry1->year, entry2->year); + result = (LONG) strcmp(entry1->year, entry2->year); } else if (column == 2) { if (ncm->sort_type & MUIV_NList_TitleMark_TypeMask) - result = (LONG) Stricmp(entry2->players, entry1->players); + result = (LONG) strcmp(entry2->players, entry1->players); else - result = (LONG) Stricmp(entry1->players, entry2->players); + result = (LONG) strcmp(entry1->players, entry2->players); } // if (col1 == 0) @@ -388,7 +388,7 @@ struct ObjApp *CreateApp(void) MUIA_NList_TitleSeparator, TRUE, MUIA_NList_Title, TRUE, MUIA_NList_EntryValueDependent, FALSE, - MUIA_NList_MinColSortable, 0, + MUIA_NList_MinColSortable, 100, MUIA_NList_Imports, MUIV_NList_Imports_Cols, MUIA_NList_Exports, MUIV_NList_Exports_Cols, End, @@ -440,7 +440,6 @@ struct ObjApp *CreateApp(void) object->LV_GenresList = ListObject, MUIA_Frame, MUIV_Frame_InputList, - MUIA_List_Active, MUIV_List_Active_Top, End; object->LV_GenresList = ListviewObject,