Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# v1.8.3-alpha0

* Added the `America/Coyhaique` time zone, pr #432.
* Optimize `del_history` task _(use single loop)_, pr #433.

# v1.8.2

Expand Down
2 changes: 1 addition & 1 deletion inc/ti/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* "-rc0"
* ""
*/
#define TI_VERSION_PRE_RELEASE "-alpha0"
#define TI_VERSION_PRE_RELEASE "-alpha1"

#define TI_MAINTAINER \
"Jeroen van der Heijden <[email protected]>"
Expand Down
1 change: 1 addition & 0 deletions src/ti/commits.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ vec_t * ti_commits_del(vec_t ** commits, ti_commits_options_t * options)
if (!vec)
return NULL;

/* must push from high to low as the `del_history` depends on this order */
commits__init(*commits, options, &begin, &end);
while (begin < end)
{
Expand Down
20 changes: 14 additions & 6 deletions src/ti/ttask.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,6 @@ static int ttask__del_history(mp_unp_t * up)
{
vec_t ** commits;
mp_obj_t obj, mp_scope, mp_id;
size_t i;

if (mp_next(up, &obj) != MP_ARR || obj.via.sz != 2 ||
mp_next(up, &mp_scope) != MP_U64 ||
Expand Down Expand Up @@ -779,21 +778,30 @@ static int ttask__del_history(mp_unp_t * up)
commits = &ti.commits;
}

for (i = obj.via.sz; i--;)
if (obj.via.sz)
{
uint32_t j = 0;
uint32_t i = obj.via.sz, j = (*commits)->n-1;

if (mp_next(up, &mp_id) != MP_U64)
{
log_critical("task `del_history`: invalid task data");
return -1;
}

for (vec_each(*commits, ti_commit_t, commit), j++)
/* we can use a single loop as we're sure the commits in the list are
* ordered from high to low */
for (vec_each_rev(*commits, ti_commit_t, commit) j--)
{
if (commit->id == mp_id.via.u64)
{
ti_commit_destroy(vec_remove(*commits, j));
break;
if (!(--i))
break;

if (mp_next(up, &mp_id) != MP_U64)
{
log_critical("task `del_history`: invalid task data");
return -1;
}
}
}
}
Expand Down