aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--trace-view-store.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/trace-view-store.c b/trace-view-store.c
index df16561..31c702b 100644
--- a/trace-view-store.c
+++ b/trace-view-store.c
@@ -1008,24 +1008,29 @@ static TraceViewRecord *
1008search_for_record_by_timestamp(TraceViewStore *store, guint64 ts) 1008search_for_record_by_timestamp(TraceViewStore *store, guint64 ts)
1009{ 1009{
1010 TraceViewRecord key; 1010 TraceViewRecord key;
1011 TraceViewRecord **rec; 1011 TraceViewRecord *rec, **prec;
1012 1012
1013 if (!store->actual_rows) 1013 if (!store->visible_rows)
1014 return NULL; 1014 return NULL;
1015 1015
1016 if (ts < store->rows[0]->timestamp) 1016 if (ts < store->rows[0]->timestamp)
1017 return NULL; 1017 return NULL;
1018 1018
1019 if (ts >= store->rows[store->actual_rows-1]->timestamp) 1019 if (ts >= store->rows[store->visible_rows-1]->timestamp)
1020 return store->rows[store->actual_rows-1]; 1020 return store->rows[store->visible_rows-1];
1021 1021
1022 key.timestamp = ts; 1022 key.timestamp = ts;
1023 rec = bsearch(&key, store->rows, store->actual_rows - 1, 1023 prec = bsearch(&key, store->rows, store->visible_rows - 2,
1024 sizeof(store->rows[0]), rows_ts_cmp); 1024 sizeof(store->rows[0]), rows_ts_cmp);
1025 1025
1026 g_assert(rec != NULL); 1026 g_assert(prec != NULL);
1027 1027
1028 return *rec; 1028 rec = *prec;
1029
1030 if (rec)
1031 printf("found row rec for %ld at %ld\n",
1032 ts, rec->timestamp);
1033 return rec;
1029} 1034}
1030 1035
1031gint trace_view_store_get_timestamp_visible_row(TraceViewStore *store, guint64 ts) 1036gint trace_view_store_get_timestamp_visible_row(TraceViewStore *store, guint64 ts)
@@ -1038,13 +1043,6 @@ gint trace_view_store_get_timestamp_visible_row(TraceViewStore *store, guint64 t
1038 if (!rec) 1043 if (!rec)
1039 return 0; 1044 return 0;
1040 1045
1041 /* Make sure the record is visible */
1042 while (rec && !rec->visible)
1043 rec++;
1044
1045 if (!rec)
1046 return 0;
1047
1048 return rec->pos - (store->page - 1) * store->rows_per_page; 1046 return rec->pos - (store->page - 1) * store->rows_per_page;
1049} 1047}
1050 1048
@@ -1067,7 +1065,7 @@ guint64 trace_view_store_get_time_from_row(TraceViewStore *store, gint row)
1067 1065
1068 row += store->start_row; 1066 row += store->start_row;
1069 1067
1070 g_return_val_if_fail (row >= 0 && row < store->actual_rows, 0); 1068 g_return_val_if_fail (row >= 0 && row < store->visible_rows, 0);
1071 1069
1072 return store->rows[row]->timestamp; 1070 return store->rows[row]->timestamp;
1073} 1071}
@@ -1078,7 +1076,7 @@ guint64 trace_view_store_get_offset_from_row(TraceViewStore *store, gint row)
1078 1076
1079 row += store->start_row; 1077 row += store->start_row;
1080 1078
1081 g_return_val_if_fail (row >= 0 && row < store->actual_rows, 0); 1079 g_return_val_if_fail (row >= 0 && row < store->visible_rows, 0);
1082 1080
1083 return store->rows[row]->offset; 1081 return store->rows[row]->offset;
1084} 1082}