mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-29 07:07:16 +00:00
75b52ac25e
* Intermediate work * Allow uncompressed words * Fix * Fix tests * Add NextUncompressed, remove g.word buffer * Code simplifications, no goroutines when workers == 1 * Fix lint| * Add test for MatchPrefix * Work on patricia * Beginning of new matcher * Fuzz test for new longest match * No skip * Fixes * Fixes * More tracing * Fixes * Fixes * Change back to old FindLongestMatches * Switch to old match finder * Print mismatches * Fix * After fix * After fix * After fix * Print pointers * Fixes and tests * Print * Print * Print * More tests * Intermediate * Fix * Fix * Prints * Fix * Fix * Initialise matchStack * Compute only once * Compute only once * Switch back * Switch to old Find * Introduce sais * Switch patricia to sais * Use sais in compressor * Use sais in compressor * Remove unused code Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local> Co-authored-by: Alex Sharp <alexsharp@Alexs-MacBook-Pro.local>
34 lines
704 B
C
34 lines
704 B
C
#include "utils.h"
|
|
|
|
int lcp_kasai(const unsigned char *T, int *SA, int *LCP, int *FTR, int *INV, int sa_size, int n)
|
|
{
|
|
|
|
for (int i = 0, j = 0; i < sa_size; i++)
|
|
{
|
|
if ((SA[i] & 1) == 0)
|
|
FTR[j++] = SA[i] >> 1;
|
|
}
|
|
|
|
for (int i = 0; i < n; i++)
|
|
INV[FTR[i]] = i;
|
|
|
|
for (int i = 0, k = 0; i < n; i++, k ? k-- : 0)
|
|
{
|
|
if (INV[i] == n - 1)
|
|
{
|
|
k = 0;
|
|
continue;
|
|
}
|
|
|
|
int j = FTR[INV[i] + 1];
|
|
|
|
while (i + k < n && j + k < n && (int)T[(i + k) * 2] != 0 &&
|
|
(int)T[(j + k) * 2] != 0 && T[(i + k) * 2 + 1] == T[(j + k) * 2 + 1])
|
|
k++;
|
|
|
|
LCP[INV[i]] = k;
|
|
}
|
|
|
|
return 0;
|
|
}
|