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

git pushed a commit to branch tytab
in repository terminology.

View the commit online.

commit 8976828c4a12929b88f6ff647f32daf2bd0db9b6
Author: [email protected] <[email protected]>
AuthorDate: Sun Mar 29 22:36:41 2026 -0600

    refactor: use eina_hash_superfast for IPC socket name
    
    Replace the hand-written XOR hash with eina_hash_superfast from Eina.
    Produces a shorter, hex-formatted socket name while using a well-tested
    hash implementation.
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
 src/bin/ipc.c      | 21 ++++-----------------
 src/bin/tycommon.c | 22 +++++-----------------
 2 files changed, 9 insertions(+), 34 deletions(-)

diff --git a/src/bin/ipc.c b/src/bin/ipc.c
index 3636e9ec..d70001d8 100644
--- a/src/bin/ipc.c
+++ b/src/bin/ipc.c
@@ -121,12 +121,10 @@ ipc_tab_shutdown(void)
 static char *
 _ipc_hash_get(void)
 {
-   char buf[1024], hash[64] = {};
+   char buf[1024], hash[64];
    const char *disp, *session, *xdg_session, *xdg_id, *xdg_seat, *xdg_vt;
-   char *s;
-   unsigned int i;
+   int h;
 
-   /* dumb stoopid hash - i'm feeling lazy */
    disp = getenv("DISPLAY");
    if (!disp) disp = "-unknown-";
    session = getenv("DBUS_SESSION_BUS_ADDRESS");
@@ -142,19 +140,8 @@ _ipc_hash_get(void)
    snprintf(buf, sizeof(buf), "%s.%s.%s.%s.%s.%s",
             disp, session, xdg_session,
             xdg_id, xdg_seat, xdg_vt);
-   memcpy(hash, "terminology-", 12);
-   memset(hash+12, 'x', 32);
-   for (i = 0, s = buf; *s; s++)
-     {
-        unsigned char c1, c2;
-
-        c1 = (((unsigned char)*s) >> 4) & 0xf;
-        c2 = ((unsigned char)*s) & 0x0f;
-        hash[12 + (i % 32)] = (((hash[12 + (i % 32)] - 'a') ^ c1) % 26) + 'a';
-        i++;
-        hash[12 + (i % 32)] = (((hash[12 + (i % 32)] - 'a') ^ c2) % 26) + 'a';
-        i++;
-     }
+   h = eina_hash_superfast(buf, strlen(buf));
+   snprintf(hash, sizeof(hash), "terminology-%08x", (unsigned int)h);
    return strdup(hash);
 }
 
diff --git a/src/bin/tycommon.c b/src/bin/tycommon.c
index e7d62646..d8ea40ac 100644
--- a/src/bin/tycommon.c
+++ b/src/bin/tycommon.c
@@ -1,4 +1,5 @@
 #include "private.h"
+#include <Eina.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stdlib.h>
@@ -117,12 +118,10 @@ end:
 char *
 ipc_hash_get(void)
 {
-   char buf[1024], hash[64] = {};
+   char buf[1024], hash[64];
    const char *disp, *session, *xdg_session, *xdg_id, *xdg_seat, *xdg_vt;
-   char *s;
-   unsigned int i;
+   int h;
 
-   /* dumb stoopid hash - i'm feeling lazy */
    disp = getenv("DISPLAY");
    if (!disp) disp = "-unknown-";
    session = getenv("DBUS_SESSION_BUS_ADDRESS");
@@ -138,19 +137,8 @@ ipc_hash_get(void)
    snprintf(buf, sizeof(buf), "%s.%s.%s.%s.%s.%s",
             disp, session, xdg_session,
             xdg_id, xdg_seat, xdg_vt);
-   memcpy(hash, "terminology-", 12);
-   memset(hash+12, 'x', 32);
-   for (i = 0, s = buf; *s; s++)
-     {
-        unsigned char c1, c2;
-
-        c1 = (((unsigned char)*s) >> 4) & 0xf;
-        c2 = ((unsigned char)*s) & 0x0f;
-        hash[12 + (i % 32)] = (((hash[12 + (i % 32)] - 'a') ^ c1) % 26) + 'a';
-        i++;
-        hash[12 + (i % 32)] = (((hash[12 + (i % 32)] - 'a') ^ c2) % 26) + 'a';
-        i++;
-     }
+   h = eina_hash_superfast(buf, strlen(buf));
+   snprintf(hash, sizeof(hash), "terminology-%08x", (unsigned int)h);
    return strdup(hash);
 }
 

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

Reply via email to