Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert InfoStore to TAILQ. #1113

Merged
merged 1 commit into from
Nov 18, 2024
Merged

Convert InfoStore to TAILQ. #1113

merged 1 commit into from
Nov 18, 2024

Conversation

somiaj
Copy link
Collaborator

@somiaj somiaj commented Nov 18, 2024

Use TAILQ instead of a linked list for InfoStore. This also reduces looping over the list multiple times in some situations.

This fixes #993.

@ThomasAdam
Copy link
Member

Hi @somiaj

I think this looks good overall. I would apply the following diff on top though:

diff --git a/fvwm/infostore.c b/fvwm/infostore.c
index 07cb5aafd..315b33127 100644
--- a/fvwm/infostore.c
+++ b/fvwm/infostore.c
@@ -83,7 +83,7 @@ void insert_metainfo(char *key, char *value)
 
 static void delete_metainfo(const char *key)
 {
-       MetaInfo *mi;
+       MetaInfo *mi = NULL;
 
        TAILQ_FOREACH(mi, &meta_info_q, entry)
        {
@@ -119,22 +119,17 @@ inline char *get_metainfo_value(const char *key)
 void print_infostore(void)
 {
        MetaInfo *mi;
-       bool not_found = 1;
-
-       fvwm_debug(__func__, "Current items in infostore (key, value):\n\n");
-       TAILQ_FOREACH(mi, &meta_info_q, entry)
-       {
-               fvwm_debug(__func__, "%s\t%s\n", mi->key, mi->value);
-               not_found = 0;
-       }
 
-       if (not_found)
-       {
+       if (TAILQ_EMPTY(&meta_info_q)) {
                fvwm_debug(__func__,
                           "No items are currently stored in the infostore.\n");
                return;
        }
 
+       fvwm_debug(__func__, "Current items in infostore (key, value):\n\n");
+       TAILQ_FOREACH(mi, &meta_info_q, entry)
+               fvwm_debug(__func__, "%s\t%s", mi->key, mi->value);
+
        return;
 }

@ThomasAdam ThomasAdam self-assigned this Nov 18, 2024
@ThomasAdam ThomasAdam added the type:enhancement Augmenting an existing feature label Nov 18, 2024
@ThomasAdam ThomasAdam added this to the 1.1.1 milestone Nov 18, 2024
Use TAILQ instead of a linked list for InfoStore. This also reduces
looping over the list multiple times in some situations.

This fixes #993.
@somiaj somiaj force-pushed the js/infostore-tailq branch from 7980e2b to 4c3d577 Compare November 18, 2024 19:03
@somiaj
Copy link
Collaborator Author

somiaj commented Nov 18, 2024

Patched applied, thanks.

@ThomasAdam ThomasAdam merged commit 603b262 into main Nov 18, 2024
12 checks passed
@ThomasAdam ThomasAdam deleted the js/infostore-tailq branch November 18, 2024 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:enhancement Augmenting an existing feature
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

InfoStore: rewrite internals to use TAILQ instead of a linked list.
2 participants