| 276 | } |
| 277 | |
| 278 | const DexFile::MethodId* DexFile::FindMethodId(const DexFile::TypeId& declaring_klass, |
| 279 | const DexFile::StringId& name, |
| 280 | const DexFile::ProtoId& signature) const { |
| 281 | // Binary search MethodIds knowing that they are sorted by class_idx, name_idx then proto_idx |
| 282 | const dex::TypeIndex class_idx = GetIndexForTypeId(declaring_klass); |
| 283 | const dex::StringIndex name_idx = GetIndexForStringId(name); |
| 284 | const uint16_t proto_idx = GetIndexForProtoId(signature); |
| 285 | int32_t lo = 0; |
| 286 | int32_t hi = NumMethodIds() - 1; |
| 287 | while (hi >= lo) { |
| 288 | int32_t mid = (hi + lo) / 2; |
| 289 | const DexFile::MethodId& method = GetMethodId(mid); |
| 290 | if (class_idx > method.class_idx_) { |
| 291 | lo = mid + 1; |
| 292 | } else if (class_idx < method.class_idx_) { |
| 293 | hi = mid - 1; |
| 294 | } else { |
| 295 | if (name_idx > method.name_idx_) { |
| 296 | lo = mid + 1; |
| 297 | } else if (name_idx < method.name_idx_) { |
| 298 | hi = mid - 1; |
| 299 | } else { |
| 300 | if (proto_idx > method.proto_idx_) { |
| 301 | lo = mid + 1; |
| 302 | } else if (proto_idx < method.proto_idx_) { |
| 303 | hi = mid - 1; |
| 304 | } else { |
| 305 | return &method; |
| 306 | } |
| 307 | } |
| 308 | } |
| 309 | } |
| 310 | return nullptr; |
| 311 | } |
| 312 | |
| 313 | const DexFile::StringId* DexFile::FindStringId(const char* string) const { |
| 314 | int32_t lo = 0; |
nothing calls this directly
no outgoing calls
no test coverage detected