| 1202 | } |
| 1203 | |
| 1204 | private static int copyFromCompoundDictionary(State s, int fence) { |
| 1205 | int pos = s.pos; |
| 1206 | final int origPos = pos; |
| 1207 | while (s.cdBrLength != s.cdBrCopied) { |
| 1208 | final int space = fence - pos; |
| 1209 | final int chunkLength = s.cdChunkOffsets[s.cdBrIndex + 1] - s.cdChunkOffsets[s.cdBrIndex]; |
| 1210 | final int remChunkLength = chunkLength - s.cdBrOffset; |
| 1211 | int length = s.cdBrLength - s.cdBrCopied; |
| 1212 | if (length > remChunkLength) { |
| 1213 | length = remChunkLength; |
| 1214 | } |
| 1215 | if (length > space) { |
| 1216 | length = space; |
| 1217 | } |
| 1218 | Utils.copyBytes( |
| 1219 | s.ringBuffer, pos, s.cdChunks[s.cdBrIndex], s.cdBrOffset, s.cdBrOffset + length); |
| 1220 | pos += length; |
| 1221 | s.cdBrOffset += length; |
| 1222 | s.cdBrCopied += length; |
| 1223 | if (length == remChunkLength) { |
| 1224 | s.cdBrIndex++; |
| 1225 | s.cdBrOffset = 0; |
| 1226 | } |
| 1227 | if (pos >= fence) { |
| 1228 | break; |
| 1229 | } |
| 1230 | } |
| 1231 | return pos - origPos; |
| 1232 | } |
| 1233 | |
| 1234 | /** |
| 1235 | * Actual decompress implementation. |