Remove invocation of v layer cache in r_io_desc_read ##io

This commit is contained in:
condret 2022-12-12 06:09:15 +01:00
parent 49160ba96c
commit 1ce8535e90
2 changed files with 3 additions and 18 deletions

View File

@ -378,18 +378,10 @@ R_API bool r_io_cache_write_at(RIO *io, ut64 addr, ut8 *buf, int len) {
R_API bool r_io_cache_read_at(RIO *io, ut64 addr, ut8 *buf, int len) {
r_return_val_if_fail (io && buf && (len > 0), false);
bool ret = true;
if (io->va) {
ret = r_io_bank_read_at (io, io->bank, addr, buf, len);
} else if (io->desc) {
ret = (r_io_desc_read_at (io->desc, addr, buf, len) > 0);
}
if (!ret) {
return false;
}
RInterval itv = (RInterval){addr, len};
RRBNode *node = _find_entry_ci_node (io->cache->tree, &itv);
IOCacheItem *ci = node? (IOCacheItem *)node->data: NULL;
const bool ret = !!ci;
while (ci && r_itv_overlap (ci->tree_itv[0], itv)) {
node = r_rbnode_next (node);
RInterval its = r_itv_intersect (ci->tree_itv[0], itv);
@ -398,7 +390,7 @@ R_API bool r_io_cache_read_at(RIO *io, ut64 addr, ut8 *buf, int len) {
r_itv_size (its));
ci = node? (IOCacheItem *)node->data: NULL;
}
return true;
return ret;
}
R_API bool r_io_cache_at(RIO *io, ut64 addr) {

View File

@ -201,15 +201,8 @@ R_API int r_io_desc_read(RIODesc *desc, ut8 *buf, int len) {
return -1;
}
ut64 seek = r_io_desc_seek (desc, 0LL, R_IO_SEEK_CUR);
if (desc->io->cachemode) {
if (seek != UT64_MAX && r_io_cache_at (desc->io, seek)) {
return r_io_cache_read (desc->io, seek, buf, len);
}
}
int ret = r_io_plugin_read (desc, buf, len);
if (ret > 0 && desc->io->cachemode) {
r_io_cache_write (desc->io, seek, buf, len);
} else if ((ret > 0) && desc->io && (desc->io->p_cache & 1)) {
if ((ret > 0) && desc->io && (desc->io->p_cache & 1)) {
ret = r_io_desc_cache_read (desc, seek, buf, ret);
}
return ret;