diff options
| -rw-r--r-- | main.c | 7 | ||||
| -rw-r--r-- | readme.md | 3 |
2 files changed, 6 insertions, 4 deletions
@@ -54,7 +54,7 @@ typedef struct { typedef struct { task_st *tasks; size_t count; // Will always be equal or less than capacity. - size_t capacity; // Limited to PTRDIFF_MAX. + size_t capacity; // Will always be equal or less than PTRDIFF_MAX (see MAX_DATABASE_TASKS). ptrdiff_t active_task; // Will always be less than capacity/count. ptrdiff_t selected_task; // Will always be less than capacity/count. int64_t modified_on; @@ -288,8 +288,9 @@ bool create_task(database_st *db, task_st **task) { // If necessary, expand database capacity. size_t current_capacity = db->capacity; if((db->count + 1) > current_capacity) { - size_t new_capacity = current_capacity == 0 ? 2 : - current_capacity > MAX_DATABASE_TASKS >> 1 ? MAX_DATABASE_TASKS : + size_t new_capacity = + current_capacity == 0 ? 2 : + current_capacity > (MAX_DATABASE_TASKS >> 1) ? MAX_DATABASE_TASKS : current_capacity << 1; task_st *new_tasks = realloc(db->tasks, new_capacity * SIZEOF_TASK_ST); @@ -41,7 +41,8 @@ Task Time Tracker - [x] Check if next/previous is safe against overflows/underflows using https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html - [x] Confirm delete_task operation by show confirmation message on selected line (horizontally centered). - [x] Check totals update speedup using https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html - - For 1M entries, generic C code runs in 12.0ms while special approaches using builtins or SIMD takes around 9.5ms. Not worth the effort. + - For 1M entries, generic C code runs in 12.0ms while special approaches using builtins or SIMD takes around 9.5ms. + - Used optimization described [here](https://stackoverflow.com/questions/17580118/signed-saturated-add-of-64-bit-ints). - [x] Allow to jump to specific task by index number using key `g` and `G`; - [x] Move task to (using task_t tmp_task + memcpy) using key `m` and `M`; - [x] Rethink keys; |
