diff options
| author | Mark Young <marky@lunarg.com> | 2017-05-09 15:23:33 -0600 |
|---|---|---|
| committer | Mark Young <marky@lunarg.com> | 2017-05-09 16:33:05 -0600 |
| commit | b9fc19dbd6a4e5f2a079a5aa6a7efbcd1be4dedd (patch) | |
| tree | ab90472d3fa604cd229421518db88730a38664c0 | |
| parent | 3a9a2cfa67d95b5b4c93a14ef39c08d0d9c17599 (diff) | |
| download | usermoji-b9fc19dbd6a4e5f2a079a5aa6a7efbcd1be4dedd.tar.xz | |
loader: Optimize layer removal
In the case we remove a meta-layer, use memmove once, not in an
array.
Change-Id: Ia7496c4436e987011a0ad504a096c15f9d320c28
| -rw-r--r-- | loader/loader.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/loader/loader.c b/loader/loader.c index 0e884c5d..45af17e4 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -2028,14 +2028,14 @@ static void verify_all_meta_layers(const struct loader_instance *inst, struct lo // Delete the component layers loader_instance_heap_free(inst, prop->component_layer_names); - // Remove the current invalid meta-layer from the layer list - for (uint32_t j = i + 1; j < instance_layers->count; j++) { - // Use memmove since we are overlapping the source and destination addresses. - memmove(&instance_layers->list[j - 1], &instance_layers->list[j], sizeof(struct loader_layer_properties)); - } - instance_layers->count--; + // Remove the current invalid meta-layer from the layer list. Use memmove since we are + // overlapping the source and destination addresses. + memmove(&instance_layers->list[i], &instance_layers->list[i + 1], + sizeof(struct loader_layer_properties) * (instance_layers->count - 1 - i)); - // Decrement the loop index so we re-check this. + // Decrement the count (because we now have one less) and decrement the loop index since we need to + // re-check this index. + instance_layers->count--; i--; } } |
