From 9fda4e3c22475059f4910d3072e01c4436bfeca9 Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Thu, 28 Mar 2013 00:08:17 +0100 Subject: [PATCH] lp#1056378: make end to nonsensical premature 8-bit optimization - 128 lanes are _not_ enough for everyone --- gitg/gitg-cell-renderer-path.c | 8 ++++---- libgitg/gitg-color.c | 6 +++--- libgitg/gitg-color.h | 2 +- libgitg/gitg-lane.h | 2 +- libgitg/gitg-lanes.c | 40 ++++++++++++++++++++-------------------- libgitg/gitg-lanes.h | 2 +- libgitg/gitg-repository.c | 4 ++-- libgitg/gitg-revision.c | 8 ++++---- libgitg/gitg-revision.h | 6 +++--- 9 files changed, 39 insertions(+), 39 deletions(-) diff --git a/gitg/gitg-cell-renderer-path.c b/gitg/gitg-cell-renderer-path.c index 97902ee..e2ae957 100644 --- a/gitg/gitg-cell-renderer-path.c +++ b/gitg/gitg-cell-renderer-path.c @@ -151,7 +151,7 @@ static void draw_arrow (GitgCellRendererPath *self, cairo_t *cr, const GdkRectangle *area, - gint8 laneidx, + gint32 laneidx, gboolean top) { gdouble cw = self->priv->lane_width; @@ -187,7 +187,7 @@ draw_paths_real (GitgCellRendererPath *self, } GSList *lanes = gitg_revision_get_lanes (revision); - gint8 to = 0; + gint32 to = 0; gdouble cw = self->priv->lane_width; gdouble ch = area->height / 2.0; GitgLane *lane; @@ -201,7 +201,7 @@ draw_paths_real (GitgCellRendererPath *self, for (item = lane->from; item; item = item->next) { - gint8 from = (gint8)GPOINTER_TO_INT (item->data); + gint32 from = (gint32)GPOINTER_TO_INT (item->data); cairo_move_to (cr, area->x + from * cw + cw / 2.0, area->y + yoffset * ch); @@ -241,7 +241,7 @@ draw_arrows (GitgCellRendererPath *self, const GdkRectangle *area) { GSList *item; - gint8 to = 0; + gint32 to = 0; for (item = gitg_revision_get_lanes (self->priv->revision); item; item = item->next) { diff --git a/libgitg/gitg-color.c b/libgitg/gitg-color.c index d5eeb85..f13dd77 100644 --- a/libgitg/gitg-color.c +++ b/libgitg/gitg-color.c @@ -23,7 +23,7 @@ #include "gitg-color.h" #include -static gint8 current_index = 0; +static gint32 current_index = 0; static gchar const *palette[] = { "#c4a000", @@ -72,10 +72,10 @@ gitg_color_set_cairo_source (GitgColor *color, cairo_t *cr) cairo_set_source_rgb(cr, r, g, b); } -static gint8 +static gint32 next_index () { - gint8 next = current_index++; + gint32 next = current_index++; if (current_index == sizeof(palette) / sizeof(gchar const *)) current_index = 0; diff --git a/libgitg/gitg-color.h b/libgitg/gitg-color.h index c3c9bd3..1968597 100644 --- a/libgitg/gitg-color.h +++ b/libgitg/gitg-color.h @@ -33,7 +33,7 @@ typedef struct _GitgColor GitgColor; struct _GitgColor { gulong ref_count; - gint8 index; + gint32 index; }; void gitg_color_reset (void); diff --git a/libgitg/gitg-lane.h b/libgitg/gitg-lane.h index 61664db..4ce0737 100644 --- a/libgitg/gitg-lane.h +++ b/libgitg/gitg-lane.h @@ -47,7 +47,7 @@ typedef struct { GitgColor *color; /** Pointer to color */ GSList *from; /** List of lanes merging on this lane */ - gint8 type; + gint32 type; } GitgLane; typedef struct diff --git a/libgitg/gitg-lanes.c b/libgitg/gitg-lanes.c index 41b8650..f3aaa61 100644 --- a/libgitg/gitg-lanes.c +++ b/libgitg/gitg-lanes.c @@ -46,7 +46,7 @@ typedef struct typedef struct { GitgColor *color; - gint8 index; + gint32 index; gchar const *from; gchar const *to; } CollapsedLane; @@ -109,10 +109,10 @@ free_lanes (GitgLanes *lanes) static LaneContainer * find_lane_by_hash (GitgLanes *lanes, gchar const *hash, - gint8 *pos) + gint32 *pos) { GSList *item; - gint8 p = 0; + gint32 p = 0; if (!hash) { @@ -344,14 +344,14 @@ lane_container_next (LaneContainer *container, static void update_lane_merge_indices (GSList *from, - gint8 index, + gint32 index, gint direction) { GSList *item; for (item = from; item; item = g_slist_next (item)) { - gint8 idx = GPOINTER_TO_INT (item->data); + gint32 idx = GPOINTER_TO_INT (item->data); if ((direction < 0 && idx > index) || (direction > 0 && idx >= index)) { @@ -362,7 +362,7 @@ update_lane_merge_indices (GSList *from, static void update_merge_indices (GSList *lanes, - gint8 index, + gint32 index, gint direction) { GSList *item; @@ -378,7 +378,7 @@ update_merge_indices (GSList *lanes, static void add_collapsed (GitgLanes *lanes, LaneContainer *container, - gint8 index) + gint32 index) { CollapsedLane *collapsed = collapsed_lane_new (container); collapsed->index = index; @@ -389,7 +389,7 @@ add_collapsed (GitgLanes *lanes, static void collapse_lane (GitgLanes *lanes, LaneContainer *container, - gint8 index) + gint32 index) { /* backtrack for inactive-collapse revisions and remove this container from those revisions, appropriately updating merge indices etc */ @@ -409,7 +409,7 @@ collapse_lane (GitgLanes *lanes, GSList *collapsed = g_slist_nth(lns, index); GitgLane *lane = (GitgLane *)collapsed->data; - gint8 newindex = GPOINTER_TO_INT(lane->from->data); + gint32 newindex = GPOINTER_TO_INT(lane->from->data); lns = gitg_revision_remove_lane(revision, lane); @@ -445,8 +445,8 @@ collapse_lane (GitgLanes *lanes, static void update_current_lanes_merge_indices (GitgLanes *lanes, - gint8 index, - gint8 direction) + gint32 index, + gint32 direction) { GSList *item; @@ -462,7 +462,7 @@ static void collapse_lanes (GitgLanes *lanes) { GSList *item = lanes->priv->lanes; - gint8 index = 0; + gint32 index = 0; while (item) { @@ -490,9 +490,9 @@ collapse_lanes (GitgLanes *lanes) } } -static gint8 +static gint32 ensure_correct_index (GitgRevision *revision, - gint8 index) + gint32 index) { guint len = g_slist_length (gitg_revision_get_lanes (revision)); @@ -509,11 +509,11 @@ expand_lane (GitgLanes *lanes, CollapsedLane *lane) { GSList *item; - gint8 index = lane->index; + gint32 index = lane->index; GitgLane *ln = gitg_lane_new_with_color (lane->color); guint len = g_slist_length (lanes->priv->lanes); - gint8 next; + gint32 next; if (index > len) { @@ -614,7 +614,7 @@ static void init_next_layer (GitgLanes *lanes) { GSList *item = lanes->priv->lanes; - gint8 index = 0; + gint32 index = 0; /* Initialize new set of lanes based on 'lanes'. It copies the lane (refs the color) and adds the lane index as a merge (so it basicly represents @@ -628,7 +628,7 @@ init_next_layer (GitgLanes *lanes) } static void -prepare_lanes (GitgLanes *lanes, GitgRevision *next, gint8 *pos) +prepare_lanes (GitgLanes *lanes, GitgRevision *next, gint32 *pos) { LaneContainer *mylane; guint num; @@ -647,7 +647,7 @@ prepare_lanes (GitgLanes *lanes, GitgRevision *next, gint8 *pos) /* Iterate over all parents and find them a lane */ for (i = 0; i < num; ++i) { - gint8 lnpos; + gint32 lnpos; LaneContainer *container = find_lane_by_hash (lanes, parents[i], &lnpos); if (container) @@ -710,7 +710,7 @@ prepare_lanes (GitgLanes *lanes, GitgRevision *next, gint8 *pos) } GSList * -gitg_lanes_next (GitgLanes *lanes, GitgRevision *next, gint8 *nextpos) +gitg_lanes_next (GitgLanes *lanes, GitgRevision *next, gint32 *nextpos) { LaneContainer *mylane; GSList *res; diff --git a/libgitg/gitg-lanes.h b/libgitg/gitg-lanes.h index ae71757..8e02bbb 100644 --- a/libgitg/gitg-lanes.h +++ b/libgitg/gitg-lanes.h @@ -55,7 +55,7 @@ GType gitg_lanes_get_type (void) G_GNUC_CONST; GitgLanes *gitg_lanes_new(void); void gitg_lanes_reset(GitgLanes *lanes); -GSList *gitg_lanes_next(GitgLanes *lanes, GitgRevision *next, gint8 *mylane); +GSList *gitg_lanes_next(GitgLanes *lanes, GitgRevision *next, gint32 *mylane); G_END_DECLS diff --git a/libgitg/gitg-repository.c b/libgitg/gitg-repository.c index f1d1b18..2751800 100644 --- a/libgitg/gitg-repository.c +++ b/libgitg/gitg-repository.c @@ -865,7 +865,7 @@ append_revision (GitgRepository *repository, GitgRevision *rv) { GSList *lanes; - gint8 mylane = 0; + gint32 mylane = 0; if (repository->priv->size == 0) { @@ -1158,7 +1158,7 @@ repository_relane (GitgRepository *repository) for (i = 0; i < repository->priv->size; ++i) { - gint8 mylane; + gint32 mylane; GitgRevision *revision = repository->priv->storage[i]; GSList *lanes = gitg_lanes_next (repository->priv->lanes, diff --git a/libgitg/gitg-revision.c b/libgitg/gitg-revision.c index 579c878..37ca641 100644 --- a/libgitg/gitg-revision.c +++ b/libgitg/gitg-revision.c @@ -45,7 +45,7 @@ struct _GitgRevision char sign; GSList *lanes; - gint8 mylane; + gint32 mylane; }; G_DEFINE_BOXED_TYPE (GitgRevision, gitg_revision, gitg_revision_ref, gitg_revision_unref) @@ -303,7 +303,7 @@ update_lane_type (GitgRevision *revision) void gitg_revision_set_lanes (GitgRevision *revision, GSList *lanes, - gint8 mylane) + gint32 mylane) { free_lanes (revision); revision->lanes = lanes; @@ -316,7 +316,7 @@ gitg_revision_set_lanes (GitgRevision *revision, update_lane_type (revision); } -gint8 +gint32 gitg_revision_get_mylane (GitgRevision *revision) { return revision->mylane; @@ -324,7 +324,7 @@ gitg_revision_get_mylane (GitgRevision *revision) void gitg_revision_set_mylane (GitgRevision *revision, - gint8 mylane) + gint32 mylane) { g_return_if_fail (mylane >= 0); diff --git a/libgitg/gitg-revision.h b/libgitg/gitg-revision.h index e01a141..72051d7 100644 --- a/libgitg/gitg-revision.h +++ b/libgitg/gitg-revision.h @@ -64,13 +64,13 @@ gchar **gitg_revision_get_parents (GitgRevision *revision); GSList *gitg_revision_get_lanes (GitgRevision *revision); GitgLane *gitg_revision_get_lane (GitgRevision *revision); -void gitg_revision_set_lanes (GitgRevision *revision, GSList *lanes, gint8 mylane); +void gitg_revision_set_lanes (GitgRevision *revision, GSList *lanes, gint32 mylane); GSList *gitg_revision_remove_lane (GitgRevision *revision, GitgLane *lane); GSList *gitg_revision_insert_lane (GitgRevision *revision, GitgLane *lane, gint index); -gint8 gitg_revision_get_mylane (GitgRevision *revision); -void gitg_revision_set_mylane (GitgRevision *revision, gint8 mylane); +gint32 gitg_revision_get_mylane (GitgRevision *revision); +void gitg_revision_set_mylane (GitgRevision *revision, gint32 mylane); void gitg_revision_set_sign(GitgRevision *revision, char sign); char gitg_revision_get_sign(GitgRevision *revision); -- 1.8.1.5