gbranden pushed a commit to branch master
in repository groff.

commit 1b19f9a4f7ed1ce78f0a4f070552579ab890dbc2
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Jul 1 23:50:01 2026 -0500

    [libgroff]: Remove `string::remove_spaces()`.
    
    It no longer has any call sites.
    
    * src/include/stringclass.h (class string): Delete declaration.
    
    * src/libs/libgroff/string.cpp (string::remove_spaces): Delete.
---
 ChangeLog                    |  8 ++++++++
 src/include/stringclass.h    |  1 -
 src/libs/libgroff/string.cpp | 35 -----------------------------------
 3 files changed, 8 insertions(+), 36 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 12137b9ce..acd3a8b8a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2026-07-01  G. Branden Robinson <[email protected]>
+
+       [libgroff]: Remove `string::remove_spaces()`.  It no longer has
+       any call sites.
+
+       * src/include/stringclass.h (class string): Delete declaration.
+       * src/libs/libgroff/string.cpp (string::remove_spaces): Delete.
+
 2026-06-26  G. Branden Robinson <[email protected]>
 
        * src/preproc/tbl/main.cpp (strieq, process_options)
diff --git a/src/include/stringclass.h b/src/include/stringclass.h
index 1b4a47fb9..131c13718 100644
--- a/src/include/stringclass.h
+++ b/src/include/stringclass.h
@@ -80,7 +80,6 @@ public:
   size_t json_length() const;
   const char *json_extract() const;
   void json_dump() const;
-  void remove_spaces();
   void clear();
   void move(string &);
 
diff --git a/src/libs/libgroff/string.cpp b/src/libs/libgroff/string.cpp
index 05899cdf8..eb01c3078 100644
--- a/src/libs/libgroff/string.cpp
+++ b/src/libs/libgroff/string.cpp
@@ -462,41 +462,6 @@ void string::json_dump() const
   free(const_cast<char *>(repr));
 }
 
-// TODO: This function has 1 call site, in tbl/main.cpp:process_data().
-// Consider either open-coding this logic there, or generalizing this
-// function to a `filter()` that takes a character parameter.
-void string::remove_spaces()
-{
-  // This method is arguably inefficient, but see above regarding the
-  // one call site.
-  size_t l = len - 1;
-  while ((l < len) && (ptr[l] == ' '))
-    l--;
-  char *p = ptr;
-  if (l > 0)
-    while (*p == ' ') {
-      p++;
-      l--;
-    }
-  if ((len - 1) != l) {
-    len = l + 1;
-    char *tmp = 0 /* nullptr */;
-    assert(sz > 0);
-    try {
-      tmp = new char[sz];
-    }
-    catch (const std::bad_alloc &exc) {
-      fatal("cannot allocate %1 bytes for removal of spaces",
-           " from string", sz);
-    }
-    memset(tmp, 0, sz);
-    memcpy(tmp, p, len);
-    delete[] ptr;
-    ptr = tmp;
-    assert(ptr != 0 /* nullptr */);
-  }
-}
-
 void put_string(const string &s, FILE *fp)
 {
   size_t len = s.length();

_______________________________________________
groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to