Minor improvements (some of #1465) (#1493)

* lib/memory.py: use 'if collection' instead of 'if len(collection) > 0'

* commands/__init__.py: use 'not line' instead of 'len(line)==0'

* hexdump.py: use 'not data' instead of 'len(data)==0'

* commands/nearpc.py: use `if p` instead of `if len("%s" % p)>0`

I double checked that this works fine:
```
pwndbg> set nearpc-branch-marker-contiguous
Set contiguous branch marker line for nearpc command to ''.
pwndbg> pi str(pwndbg.commands.nearpc.nearpc_branch_marker_contiguous)
''
pwndbg> pi bool(pwndbg.commands.nearpc.nearpc_branch_marker_contiguous)
False
```
pull/1499/head
Disconnect3d 3 years ago committed by GitHub
parent db1fbdf251
commit dbaba63a74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -52,7 +52,7 @@ def list_current_commands():
line = line.strip()
# Skip non-command entries
if (
len(line) == 0
not line
or line.startswith("Command class:")
or line.startswith("Unclassified commands")
):

@ -191,7 +191,7 @@ def nearpc(pc=None, lines=None, to_string=False, emulate=False):
# Otherwise if it's a branch and it *is* contiguous, just put
# and empty line.
elif prev and any(g in prev.groups for g in (CS_GRP_CALL, CS_GRP_JUMP, CS_GRP_RET)):
if len("%s" % nearpc_branch_marker_contiguous) > 0:
if nearpc_branch_marker_contiguous:
result.append("%s" % nearpc_branch_marker_contiguous)
# For syscall instructions, put the name on the side

@ -87,7 +87,7 @@ def hexdump(
load_color_scheme()
# If there's nothing to print, just print the offset and address and return
if len(data) == 0:
if not data:
yield H.offset("+%04x " % len(data)) + H.address("%#08x " % (address + len(data)))
# Don't allow iterating over this generator again

@ -94,7 +94,7 @@ class Page:
@property
def is_memory_mapped_file(self) -> bool:
return len(self.objfile) > 0 and self.objfile[0] != "[" and self.objfile != "<pt>"
return self.objfile and self.objfile[0] != "[" and self.objfile != "<pt>"
@property
def read(self) -> bool:

Loading…
Cancel
Save