| 66 | }; |
| 67 | |
| 68 | unsigned Compressor::nonCompressableRun(unsigned length) |
| 69 | { |
| 70 | fb_assert(length && length <= MAX_NONCOMP_RUN); |
| 71 | |
| 72 | auto result = length; |
| 73 | |
| 74 | // If the prior run was also non-compressable and it wasn't fully utilized, |
| 75 | // merge our run there. Otherwise, create a new run. |
| 76 | |
| 77 | if (m_runs.hasData() && m_runs.back() > 0 && m_runs.back() < MAX_NONCOMP_RUN) |
| 78 | { |
| 79 | const auto max = MIN(MAX_NONCOMP_RUN - m_runs.back(), length); |
| 80 | length -= max; |
| 81 | m_runs.back() += max; |
| 82 | } |
| 83 | |
| 84 | if (length) |
| 85 | { |
| 86 | m_runs.add(length); |
| 87 | result++; |
| 88 | } |
| 89 | |
| 90 | fb_assert(m_runs.back() > 0 && m_runs.back() <= MAX_NONCOMP_RUN); |
| 91 | |
| 92 | return result; |
| 93 | } |
| 94 | |
| 95 | Compressor::Compressor(thread_db* tdbb, ULONG length, const UCHAR* data) |
| 96 | : Compressor( |