From fbbf2c68c63e357f556cd17bd160b48e1e5bac2d Mon Sep 17 00:00:00 2001
From: "Sven M. Hallberg" <pesco@khjk.org>
Date: Wed, 1 Mar 2023 17:43:38 +0000
Subject: [PATCH] get rid of ts variable in act_txtobj

The node member of TextState_T seems to be written only in one place in
parse_pagenode(), and in such a way that the assertion "ts->node == node"
must always hold. So we might as well assign node where it said ts->node
and get rid of ts completely.
---
 pdf.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/pdf.c b/pdf.c
index e814a39..daca61d 100644
--- a/pdf.c
+++ b/pdf.c
@@ -2015,14 +2015,11 @@ act_txtobj(const HParseResult *p, void *u)
 
 	tstr = h_arena_malloc(p->arena, sizeof(uint8_t) * textlen);
 	int idx=0;
-	TextState_T      *ts;
 	// Now concatenate the pieces
 	for (int i =0; i < opstream->seq->used; i++) {
 		txte = H_CAST(TextEntry, opstream->seq->elements[i]);
 		assert(txte != NULL);
 		assert(txte->node == node);
-		ts   = &txte->node->ts;
-		assert(ts->node == node);
 
 		// Process the text operators
 		switch (txte->type) {
@@ -2114,7 +2111,7 @@ act_txtobj(const HParseResult *p, void *u)
 	txtobj->tstr.nchars  = textlen;
 	txtobj->tstr.tobj    = opstream;
 	if (textlen)
-		txtobj->node = ts->node;
+		txtobj->node = node;
 	else
 		txtobj->node = NULL;
 	// pretty print the information
-- 
GitLab