rupertreynolds
rupertreynolds

Reputation: 55

I am seeking a practical algorithm for a compiler to compress string literal data

I'm writing a hobby compiler and I'm looking for a sensible way to compress string constants. For a larger program, it isn't practical to try every possible permutation (then checking whether each new string constant is already part of the constant data).

The only technique I found so far is to add the longest strings first, and hope I get some matches. This doesn't catch every case.

For a trivial example, if source code contains string constants "Who is General Failure, and why is he trying to read my hard disk" "disk" "and why" "Doctor Who" "diskette"

The staring constants would be "Doctor Who is General Failure, and why is he trying to read my hard diskette"

Any guidance apart from "don't bother" is welcome.

TVMIA

Roops

Upvotes: 0

Views: 68

Answers (0)

Related Questions