gallium/util: reduce util_snprintf() calls in debug_flush_might_flush_cb()
authorBrian Paul <brianp@vmware.com>
Mon, 24 Apr 2017 18:58:22 +0000 (12:58 -0600)
committerBrian Paul <brianp@vmware.com>
Wed, 26 Apr 2017 17:38:00 +0000 (11:38 -0600)
We only need to construct the debug message if the mapped_sync flag is set.
This should make the function faster since the flag is usually false.

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
src/gallium/auxiliary/util/u_debug_flush.c

index fe96e09aadfdf1f36982680100ad5bc038fe5feb..98a69b2de057585041f346aff36aac931a4469be 100644 (file)
@@ -320,14 +320,15 @@ debug_flush_might_flush_cb(void *key, void *value, void *data)
    struct debug_flush_item *item =
       (struct debug_flush_item *) value;
    struct debug_flush_buf *fbuf = item->fbuf;
-   const char *reason = (const char *) data;
-   char message[80];
-
-   util_snprintf(message, sizeof(message),
-                 "%s referenced mapped buffer detected.", reason);
 
    mtx_lock(&fbuf->mutex);
    if (fbuf->mapped_sync) {
+      const char *reason = (const char *) data;
+      char message[80];
+
+      util_snprintf(message, sizeof(message),
+                    "%s referenced mapped buffer detected.", reason);
+
       debug_flush_alert(message, reason, 3, item->bt_depth, TRUE, TRUE, NULL);
       debug_flush_alert(NULL, "Map", 0, fbuf->bt_depth, TRUE, FALSE,
                         fbuf->map_frame);