summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lundqvist <daniel@malarhojden.nu>2024-06-17 12:07:38 +0200
committerDaniel Lundqvist <daniel@malarhojden.nu>2024-06-17 12:16:37 +0200
commitd4fa377ab159791a7790369c8b34dfd8bddb3645 (patch)
tree7c2844e1c37d8a8f6f867d2330045ffd89ee9fab
parentcce2abf00fa2c9a695f1d0e5c931c70c1ba579cf (diff)
all: Use XInternAtoms where appropriateHEADmaster
Instead of calling XInternAtom once per atom, call XInternAtoms once instead. This is both simpler code and should reduce network traffic. Although the latter is probably not measurable.
-rw-r--r--src/Text.c6
-rw-r--r--src/TextAction.c6
2 files changed, 5 insertions, 7 deletions
diff --git a/src/Text.c b/src/Text.c
index 960214c..9cdf61f 100644
--- a/src/Text.c
+++ b/src/Text.c
@@ -3126,15 +3126,15 @@ _XawTextSelectionList(TextWidget ctx, String *list, Cardinal nelems)
{
Atom *sel = ctx->text.s.selections;
Display *dpy = XtDisplay((Widget)ctx);
- int n;
if (nelems > (Cardinal)ctx->text.s.array_size) {
sel = (Atom *)XtRealloc((char *)sel, (Cardinal)(sizeof(Atom) * (size_t)nelems));
ctx->text.s.array_size = (int)nelems;
ctx->text.s.selections = sel;
}
- for (n = (int)nelems; --n >= 0; sel++, list++)
- *sel = XInternAtom(dpy, *list, False);
+
+ XInternAtoms(dpy, (char **)list, nelems, False, sel);
+
ctx->text.s.atom_count = (int)nelems;
return (ctx->text.s.selections);
diff --git a/src/TextAction.c b/src/TextAction.c
index 09e22f2..806395e 100644
--- a/src/TextAction.c
+++ b/src/TextAction.c
@@ -2788,8 +2788,7 @@ ExtendEnd(Widget w, XEvent *event, String *params, Cardinal *num_params)
static void
SelectSave(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
- int num_atoms, n;
- Atom *sel;
+ int num_atoms;
Display *dpy = XtDisplay(w);
Atom selections[256];
@@ -2797,8 +2796,7 @@ SelectSave(Widget w, XEvent *event, String *params, Cardinal *num_params)
num_atoms = (int)*num_params;
if (num_atoms > 256)
num_atoms = 256;
- for (sel = selections, n = 0; n < num_atoms; n++, sel++, params++)
- *sel = XInternAtom(dpy, *params, False);
+ XInternAtoms(dpy, (char **)params, num_atoms, False, selections);
_XawTextSaltAwaySelection((TextWidget)w, selections, num_atoms);
EndAction((TextWidget)w);
}