Skip to content

Commit

Permalink
deterministic sorting in SortPathShortToLongVersionMerge and SortPath…
Browse files Browse the repository at this point in the history
…ShortToLong (#234)
  • Loading branch information
DanEngelbrecht authored Jan 17, 2024
1 parent 8fc8650 commit f38bbeb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- **FIXED** `Longtail_ChangeVersion2()` can now handle workloads with a block count larger than 65535
- **FIXED** Bikeshed JobAPI implementation does efficient wait when task queue is full
- **FIXED** Bikeshed JobAPI::CreateJobs implementation now properly drains both task channels when task queue is full
- **FIXED** Make sure we retain order of assets with equal length when sorting them
- **CHANGED** Refactored all internal usage of JobAPI `ReadyJobs` with new error handling

## 0.4.1
Expand Down
36 changes: 34 additions & 2 deletions src/longtail.c
Original file line number Diff line number Diff line change
Expand Up @@ -2900,7 +2900,23 @@ static SORTFUNC(SortPathShortToLongVersionMerge)
uint32_t b = *(const uint32_t*)b_ptr;
uint32_t a_len = path_lengths[a];
uint32_t b_len = path_lengths[b];
return (a_len > b_len) ? 1 : (a_len < b_len) ? -1 : 0;
if (a_len < b_len)
{
return -1;
}
if (a_len > b_len)
{
return 1;
}
if (a < b)
{
return -1;
}
if (a > b)
{
return 1;
}
return 0;
}

int Longtail_MergeVersionIndex(
Expand Down Expand Up @@ -7196,7 +7212,23 @@ static SORTFUNC(SortPathShortToLong)
const char* b_path = &version_index->m_NameData[version_index->m_NameOffsets[b]];
size_t a_len = strlen(a_path);
size_t b_len = strlen(b_path);
return (a_len > b_len) ? 1 : (a_len < b_len) ? -1 : 0;
if (a_len < b_len)
{
return -1;
}
if (a_len > b_len)
{
return 1;
}
if (a < b)
{
return -1;
}
if (a > b)
{
return 1;
}
return 0;
}

static SORTFUNC(SortPathLongToShort)
Expand Down

0 comments on commit f38bbeb

Please sign in to comment.