summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2018-01-01 22:38:14 +0100
committerMarek Olšák <[email protected]>2018-01-27 02:09:09 +0100
commitecfd5215024b0db95379cf29b2236294720184cb (patch)
treeca9a3952f8a8900d234dc5b85f5563d5c2f3be84 /src/gallium/auxiliary
parente553cb5a68c812e33c61fdc4c6837b31089f89c2 (diff)
pb_cache: call os_time_get outside of the loop
Reviewed-by: Samuel Pitoiset <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_cache.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/gallium/auxiliary/pipebuffer/pb_cache.c b/src/gallium/auxiliary/pipebuffer/pb_cache.c
index b67e54b6b52..dd479ae7719 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_cache.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_cache.c
@@ -54,20 +54,18 @@ destroy_buffer_locked(struct pb_cache_entry *entry)
* Free as many cache buffers from the list head as possible.
*/
static void
-release_expired_buffers_locked(struct list_head *cache)
+release_expired_buffers_locked(struct list_head *cache,
+ int64_t current_time)
{
struct list_head *curr, *next;
struct pb_cache_entry *entry;
- int64_t now;
-
- now = os_time_get();
curr = cache->next;
next = curr->next;
while (curr != cache) {
entry = LIST_ENTRY(struct pb_cache_entry, curr, head);
- if (!os_time_timeout(entry->start, entry->end, now))
+ if (!os_time_timeout(entry->start, entry->end, current_time))
break;
destroy_buffer_locked(entry);
@@ -92,8 +90,10 @@ pb_cache_add_buffer(struct pb_cache_entry *entry)
mtx_lock(&mgr->mutex);
assert(!pipe_is_referenced(&buf->reference));
+ int64_t current_time = os_time_get();
+
for (i = 0; i < ARRAY_SIZE(mgr->buckets); i++)
- release_expired_buffers_locked(&mgr->buckets[i]);
+ release_expired_buffers_locked(&mgr->buckets[i], current_time);
/* Directly release any buffer that exceeds the limit. */
if (mgr->cache_size + buf->size > mgr->max_cache_size) {