if (!initialized) {
init_from_environment();
}
- if (tracked_fds_list_count == 0) {
+
+ /* tracked_fds_find() is most likely faster than calling isatty(),
+ * therefore check if we are tracking this file descriptor first. */
+ if (!tracked_fds_find(fd)) {
return 0;
}
return 0;
}
- return tracked_fds_find(fd);
+ return 1;
}
static void dup_fd(int oldfd, int newfd) {
if (!initialized) {
init_from_environment();
}
- if (tracked_fds_list_count == 0) {
- return;
- }
/* We are already tracking this file descriptor, add newfd to the list as
* it will reference the same descriptor. */
if (!initialized) {
init_from_environment();
}
- if (tracked_fds_list_count == 0) {
- return;
- }
tracked_fds_remove(fd);
}