mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-05 11:08:12 +02:00
[script] Inline the stack push
Frequently to push an object onto the stack all we need is to simply perform the struct copy - so inline it and only call the out-of-line function if we need to enlarge the stack.
This commit is contained in:
parent
565b3d6ad6
commit
83f0e6cf62
4 changed files with 39 additions and 51 deletions
|
|
@ -179,16 +179,16 @@ _init_dictionaries (csi_t *ctx)
|
|||
stack = &ctx->dstack;
|
||||
|
||||
status = _csi_stack_init (ctx, stack, 4);
|
||||
if (status)
|
||||
if (_csi_unlikely (status))
|
||||
return status;
|
||||
|
||||
/* systemdict */
|
||||
status = csi_dictionary_new (ctx, &obj);
|
||||
if (status)
|
||||
if (_csi_unlikely (status))
|
||||
return status;
|
||||
|
||||
status = _csi_stack_push (ctx, stack, &obj);
|
||||
if (status)
|
||||
if (_csi_unlikely (status))
|
||||
return status;
|
||||
|
||||
dict = obj.datum.dictionary;
|
||||
|
|
@ -196,19 +196,19 @@ _init_dictionaries (csi_t *ctx)
|
|||
/* fill systemdict with operators */
|
||||
for (odef = _csi_operators (); odef->name != NULL; odef++) {
|
||||
status = _add_operator (ctx, dict, odef);
|
||||
if (status)
|
||||
if (_csi_unlikely (status))
|
||||
return status;
|
||||
}
|
||||
|
||||
/* add constants */
|
||||
for (idef = _csi_integer_constants (); idef->name != NULL; idef++) {
|
||||
status = _add_integer_constant (ctx, dict, idef);
|
||||
if (status)
|
||||
if (_csi_unlikely (status))
|
||||
return status;
|
||||
}
|
||||
for (rdef = _csi_real_constants (); rdef->name != NULL; rdef++) {
|
||||
status = _add_real_constant (ctx, dict, rdef);
|
||||
if (status)
|
||||
if (_csi_unlikely (status))
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
@ -218,18 +218,18 @@ _init_dictionaries (csi_t *ctx)
|
|||
|
||||
/* globaldict */
|
||||
status = csi_dictionary_new (ctx, &obj);
|
||||
if (status)
|
||||
if (_csi_unlikely (status))
|
||||
return status;
|
||||
status = _csi_stack_push (ctx, stack, &obj);
|
||||
if (status)
|
||||
if (_csi_unlikely (status))
|
||||
return status;
|
||||
|
||||
/* userdict */
|
||||
status = csi_dictionary_new (ctx, &obj);
|
||||
if (status)
|
||||
if (_csi_unlikely (status))
|
||||
return status;
|
||||
status = _csi_stack_push (ctx, stack, &obj);
|
||||
if (status)
|
||||
if (_csi_unlikely (status))
|
||||
return status;
|
||||
|
||||
return CSI_STATUS_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -1815,7 +1815,7 @@ _font (csi_t *ctx)
|
|||
|
||||
/* transfer ownership of dictionary to cairo_font_face_t */
|
||||
proxy = _csi_proxy_create (ctx, font_face, font, NULL, NULL);
|
||||
if (_csi_likely (proxy == NULL)) {
|
||||
if (_csi_unlikely (proxy == NULL)) {
|
||||
cairo_font_face_destroy (font_face);
|
||||
return _csi_error (CSI_STATUS_NO_MEMORY);
|
||||
}
|
||||
|
|
@ -1925,6 +1925,7 @@ _context_get (csi_t *ctx,
|
|||
csi_name_t key)
|
||||
{
|
||||
csi_status_t status;
|
||||
csi_object_t obj;
|
||||
|
||||
if (strcmp ((char *) key, "current-point") == 0) {
|
||||
double x, y;
|
||||
|
|
@ -1939,49 +1940,25 @@ _context_get (csi_t *ctx,
|
|||
return status;
|
||||
|
||||
return CSI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (strcmp ((char *) key, "source") == 0) {
|
||||
csi_object_t obj;
|
||||
|
||||
} else if (strcmp ((char *) key, "source") == 0) {
|
||||
obj.type = CSI_OBJECT_TYPE_PATTERN;
|
||||
obj.datum.pattern = cairo_pattern_reference (cairo_get_source (cr));
|
||||
return push (&obj);
|
||||
}
|
||||
|
||||
if (strcmp ((char *) key, "target") == 0) {
|
||||
csi_object_t obj;
|
||||
|
||||
} else if (strcmp ((char *) key, "target") == 0) {
|
||||
obj.type = CSI_OBJECT_TYPE_SURFACE;
|
||||
obj.datum.surface = cairo_surface_reference (cairo_get_target (cr));
|
||||
return push (&obj);
|
||||
}
|
||||
|
||||
if (strcmp ((char *) key, "group-target") == 0) {
|
||||
csi_object_t obj;
|
||||
|
||||
} else if (strcmp ((char *) key, "group-target") == 0) {
|
||||
obj.type = CSI_OBJECT_TYPE_SURFACE;
|
||||
obj.datum.surface = cairo_surface_reference (cairo_get_group_target (cr));
|
||||
return push (&obj);
|
||||
}
|
||||
|
||||
if (strcmp ((char *) key, "scaled-font") == 0) {
|
||||
csi_object_t obj;
|
||||
|
||||
} else if (strcmp ((char *) key, "scaled-font") == 0) {
|
||||
obj.type = CSI_OBJECT_TYPE_SCALED_FONT;
|
||||
obj.datum.scaled_font = cairo_scaled_font_reference (cairo_get_scaled_font (cr));
|
||||
return push (&obj);
|
||||
}
|
||||
|
||||
if (strcmp ((char *) key, "font-face") == 0) {
|
||||
csi_object_t obj;
|
||||
|
||||
} else if (strcmp ((char *) key, "font-face") == 0) {
|
||||
obj.type = CSI_OBJECT_TYPE_FONT;
|
||||
obj.datum.font_face = cairo_font_face_reference (cairo_get_font_face (cr));
|
||||
return push (&obj);
|
||||
}
|
||||
} else
|
||||
return _proxy_get (cairo_get_user_data (cr, &_csi_proxy_key), key);
|
||||
|
||||
return _proxy_get (cairo_get_user_data (cr, &_csi_proxy_key), key);
|
||||
return push (&obj);
|
||||
}
|
||||
|
||||
static csi_status_t
|
||||
|
|
|
|||
|
|
@ -770,7 +770,8 @@ csi_private csi_status_t
|
|||
_csi_stack_grow (csi_t *ctx, csi_stack_t *stack, csi_integer_t cnt);
|
||||
|
||||
csi_private csi_status_t
|
||||
_csi_stack_push (csi_t *ctx, csi_stack_t *stack, const csi_object_t *obj);
|
||||
_csi_stack_push_internal (csi_t *ctx, csi_stack_t *stack,
|
||||
const csi_object_t *obj);
|
||||
|
||||
csi_private csi_object_t *
|
||||
_csi_stack_peek (csi_stack_t *stack, csi_integer_t i);
|
||||
|
|
@ -817,6 +818,17 @@ csi_number_get_value (const csi_object_t *obj)
|
|||
}
|
||||
}
|
||||
|
||||
static inline csi_status_t
|
||||
_csi_stack_push (csi_t *ctx, csi_stack_t *stack,
|
||||
const csi_object_t *obj)
|
||||
{
|
||||
if (_csi_unlikely (stack->len == stack->size))
|
||||
return _csi_stack_push_internal (ctx, stack, obj);
|
||||
|
||||
stack->objects[stack->len++] = *obj;
|
||||
return CSI_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static inline csi_boolean_t
|
||||
_csi_check_ostack (csi_t *ctx, csi_integer_t count)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -145,15 +145,14 @@ _csi_stack_grow (csi_t *ctx, csi_stack_t *stack, csi_integer_t cnt)
|
|||
}
|
||||
|
||||
csi_status_t
|
||||
_csi_stack_push (csi_t *ctx, csi_stack_t *stack, const csi_object_t *obj)
|
||||
_csi_stack_push_internal (csi_t *ctx, csi_stack_t *stack,
|
||||
const csi_object_t *obj)
|
||||
{
|
||||
if (_csi_unlikely (stack->len == stack->size)) {
|
||||
csi_status_t status;
|
||||
csi_status_t status;
|
||||
|
||||
status = _csi_stack_grow (ctx, stack, stack->size + 1);
|
||||
if (status)
|
||||
return status;
|
||||
}
|
||||
status = _csi_stack_grow (ctx, stack, stack->size + 1);
|
||||
if (_csi_unlikely (status))
|
||||
return status;
|
||||
|
||||
stack->objects[stack->len++] = *obj;
|
||||
return CSI_STATUS_SUCCESS;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue