mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
[qfcc] Fix indexed pointer vector indexing
The array access code was loading the vector, modifying the element, then forgetting to write the modified vector back to whence it came. However, that would be rather sub-optimal, so now when the vector is accessed by a pointer, the array code switches to field access to get at the vector element thus avoiding the need to copy the whole vector.
This commit is contained in:
parent
0d78a865c6
commit
8d4602ec61
1 changed files with 5 additions and 0 deletions
|
@ -2503,6 +2503,11 @@ array_expr (expr_t *array, expr_t *index)
|
||||||
base = new_int_expr (0);
|
base = new_int_expr (0);
|
||||||
} else {
|
} else {
|
||||||
ele_type = ev_types[array_type->type];
|
ele_type = ev_types[array_type->type];
|
||||||
|
if (array->type == ex_uexpr && array->e.expr.op == '.') {
|
||||||
|
expr_t *vec = offset_pointer_expr (array->e.expr.e1, index);
|
||||||
|
vec = cast_expr (pointer_type (ele_type), vec);
|
||||||
|
return unary_expr ('.', vec);
|
||||||
|
}
|
||||||
base = new_int_expr (0);
|
base = new_int_expr (0);
|
||||||
}
|
}
|
||||||
scale = new_int_expr (type_size (ele_type));
|
scale = new_int_expr (type_size (ele_type));
|
||||||
|
|
Loading…
Reference in a new issue