check if first charactor is \0, its faster than strlen

This commit is contained in:
xfnw 2021-08-21 15:18:37 -04:00
parent d3e9803cf2
commit 96a074bb4d

View file

@ -42,7 +42,7 @@ void *handle_connection(void *socket_desc) {
strncpy(colorcode, safestrtok(NULL, " \n"), 8); strncpy(colorcode, safestrtok(NULL, " \n"), 8);
if (xpos >= 0 && ypos >= 0 && xpos < fb_width && ypos < fb_height) { if (xpos >= 0 && ypos >= 0 && xpos < fb_width && ypos < fb_height) {
if (strlen(colorcode) == 0) { if (colorcode[0] == '\0') {
message = calloc(sizeof(char), 36); message = calloc(sizeof(char), 36);
asprintf(&message, "PX %i %i %X\n",xpos,ypos,fbdata[ypos*fb_length+xpos]); asprintf(&message, "PX %i %i %X\n",xpos,ypos,fbdata[ypos*fb_length+xpos]);
write(sock, message, strlen(message)); write(sock, message, strlen(message));