This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch desktop-restore
in repository terminology.

View the commit online.

commit 7cd890474ce8b7f0e375a4d5febb26f10cd1587d
Author: [email protected] <[email protected]>
AuthorDate: Fri Mar 20 20:39:23 2026 -0600

    refactor: use Eina_Stringshare type for stringshared fields in Session structs
    
    Replace const char * with Eina_Stringshare * for fields that hold
    stringshare references (Session_Meta.name and Session_Node string fields).
    This makes the type system reflect reality and enables using more
    efficient stringshare operations.
    
    Optimize stringshare usage patterns:
    - Use eina_stringshare_add_length() instead of strndup() +
      eina_stringshare_add() + free() to avoid unnecessary heap allocation
      (_meta_cache_build and session_list functions)
    - Use eina_stringshare_ref() instead of eina_stringshare_add() when
      the source is already a stringshare, avoiding O(n) hash probe for
      a simple O(1) refcount increment (session_meta_list and
      session_popup_load_show)
    
    These changes improve efficiency while maintaining identical external behavior.
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
 src/bin/session.c | 35 ++++++++++++++---------------------
 src/bin/session.h |  2 +-
 2 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/src/bin/session.c b/src/bin/session.c
index 0cfe0846..fe585074 100644
--- a/src/bin/session.c
+++ b/src/bin/session.c
@@ -50,12 +50,12 @@ typedef enum {
 typedef struct _Session_Node Session_Node;
 
 struct _Session_Node {
-   Eina_List       *children;
-   const char      *cwd;
-   const char      *tab_title;
-   const char      *mux_type;
-   const char      *mux_session;
-   double           split_ratio;
+   Eina_List        *children;
+   Eina_Stringshare *cwd;
+   Eina_Stringshare *tab_title;
+   Eina_Stringshare *mux_type;
+   Eina_Stringshare *mux_session;
+   double            split_ratio;
    Session_Node_Type type;
    int              active_tab;
    Eina_Bool        is_horizontal;
@@ -1341,12 +1341,8 @@ _meta_cache_build(void)
                        Session_Meta *m = calloc(1, sizeof(*m));
                        if (m)
                          {
-                            char *name = strndup(file, len - 4);
-                            if (name)
-                              {
-                                 m->name = eina_stringshare_add(name);
-                                 free(name);
-                              }
+                            m->name = eina_stringshare_add_length(file,
+                                                                   len - 4);
                             if (!m->name)
                               {
                                  free(m);
@@ -1398,13 +1394,10 @@ session_list(void)
         size_t len = strlen(file);
         if (len > 4 && !strcmp(file + len - 4, ".ses"))
           {
-             char *name = strndup(file, len - 4);
+             Eina_Stringshare *name = eina_stringshare_add_length(file,
+                                                                   len - 4);
              if (name)
-               {
-                  result = eina_list_append(result,
-                                            eina_stringshare_add(name));
-                  free(name);
-               }
+               result = eina_list_append(result, name);
           }
         eina_stringshare_del(path);
      }
@@ -1415,7 +1408,7 @@ session_list(void)
 void
 session_list_free(Eina_List *list)
 {
-   const char *name;
+   Eina_Stringshare *name;
    EINA_LIST_FREE(list, name)
      eina_stringshare_del(name);
 }
@@ -1435,7 +1428,7 @@ session_meta_list(void)
         Session_Meta *copy = calloc(1, sizeof(*copy));
         if (copy)
           {
-             copy->name = eina_stringshare_add(m->name);
+             copy->name = eina_stringshare_ref(m->name);
              result = eina_list_append(result, copy);
           }
      }
@@ -1768,7 +1761,7 @@ session_popup_load_show(Evas_Object *win, Evas_Object *base EINA_UNUSED,
         /* Store ctx and session name in button data for the callback.
          * `name` is owned by the sessions list (eina_stringshare); take
          * a reference so it survives session_list_free() below. */
-        ctx->_one_session_name_ = eina_stringshare_add(name);
+        ctx->_one_session_name_ = eina_stringshare_ref(name);
         evas_object_data_set(btn, "session_name", ctx->one_session_name);
         /* _cb_one_session_load clears ctx->one_session_name then frees the ref */
         evas_object_smart_callback_add(btn, "clicked",
diff --git a/src/bin/session.h b/src/bin/session.h
index eb8f0622..3162849a 100644
--- a/src/bin/session.h
+++ b/src/bin/session.h
@@ -22,7 +22,7 @@ void        session_list_free(Eina_List *list);
 Eina_Bool   session_del(const char *name);
 
 typedef struct {
-   const char *name;    /* eina_stringshare */
+   Eina_Stringshare *name;
 } Session_Meta;
 
 Eina_List  *session_meta_list(void);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to