(LPSZ lpsz)
| 281 | } |
| 282 | |
| 283 | @Nullable |
| 284 | private FdCacheRecord getFdCacheRecord(LPSZ lpsz) { |
| 285 | int keyIndex = openFdMapByPath.keyIndex(lpsz); |
| 286 | final FdCacheRecord holder; |
| 287 | if (keyIndex > -1) { |
| 288 | int osFd = Files.openRO(lpsz.ptr()); |
| 289 | if (osFd < 0) { |
| 290 | // Failed to open |
| 291 | holder = null; |
| 292 | } else { |
| 293 | OPEN_OS_FILE_COUNT.incrementAndGet(); |
| 294 | Utf8String path = Utf8String.newInstance(lpsz); |
| 295 | holder = createFdCacheRecord(path, mmapKeyGenerator.getAndIncrement()); |
| 296 | holder.osFd = osFd; |
| 297 | // Reuse the same Utf8String for the map key so putAt picks the |
| 298 | // Utf8String overload and skips its own newInstance() copy. |
| 299 | openFdMapByPath.putAt(keyIndex, path, holder); |
| 300 | } |
| 301 | } else { |
| 302 | holder = openFdMapByPath.valueAtQuick(keyIndex); |
| 303 | fdReuseCount++; |
| 304 | } |
| 305 | return holder; |
| 306 | } |
| 307 | |
| 308 | private int nextIndex() { |
| 309 | int raw = fdCounter.getAndIncrement(); |
no test coverage detected