Make if statement more idiomatic

This commit is contained in:
LeRoyce Pearson 2020-04-30 17:12:29 -06:00 committed by Andrew Kelley
parent 2c59f95e87
commit 42007307be

View File

@ -182,9 +182,11 @@ pub const CacheHash = struct {
if (file_path.len == 0) { if (file_path.len == 0) {
return error.InvalidFormat; return error.InvalidFormat;
} }
if (cache_hash_file.path != null and !mem.eql(u8, file_path, cache_hash_file.path.?)) { if (cache_hash_file.path) |p| {
if (!mem.eql(u8, file_path, p)) {
return error.InvalidFormat; return error.InvalidFormat;
} }
}
if (cache_hash_file.path == null) { if (cache_hash_file.path == null) {
cache_hash_file.path = try mem.dupe(self.alloc, u8, file_path); cache_hash_file.path = try mem.dupe(self.alloc, u8, file_path);