reducing ConnectionNumber calls to a bare minimum e571de83
Anselm R.Garbe · 2006-08-14 07:23 1 file(s) · +5 −4
main.c +5 −4
162 162
int
163 163
main(int argc, char *argv[])
164 164
{
165 -
	int i;
165 +
	int i, xfd;
166 166
	unsigned int mask;
167 167
	fd_set rd;
168 168
	Bool readin = True;
181 181
	if(!dpy)
182 182
		eprint("dwm: cannot open display\n");
183 183
184 +
	xfd = ConnectionNumber(dpy);
184 185
	screen = DefaultScreen(dpy);
185 186
	root = RootWindow(dpy, screen);
186 187
260 261
		FD_ZERO(&rd);
261 262
		if(readin)
262 263
			FD_SET(STDIN_FILENO, &rd);
263 -
		FD_SET(ConnectionNumber(dpy), &rd);
264 +
		FD_SET(xfd, &rd);
264 265
265 -
		i = select(ConnectionNumber(dpy) + 1, &rd, 0, 0, 0);
266 +
		i = select(xfd + 1, &rd, 0, 0, 0);
266 267
		if(i == -1 && errno == EINTR)
267 268
			continue;
268 269
		if(i < 0)
269 270
			eprint("select failed\n");
270 271
		else if(i > 0) {
271 -
			if(FD_ISSET(ConnectionNumber(dpy), &rd)) {
272 +
			if(FD_ISSET(xfd, &rd)) {
272 273
				while(XPending(dpy)) {
273 274
					XNextEvent(dpy, &ev);
274 275
					if(handler[ev.type])