Convert core:compress and core:image error checks to new union comparison.

No more need for `is_kind(err, Error_Value)`, just test err == Error_Value.
This commit is contained in:
Jeroen van Rijn
2021-05-03 15:08:34 +02:00
parent 357f66fcee
commit 59b3c472ca
8 changed files with 35 additions and 44 deletions
+4 -4
View File
@@ -107,7 +107,7 @@ text :: proc(c: Chunk) -> (res: Text, ok: bool) {
buf: bytes.Buffer;
zlib_error := zlib.inflate_from_byte_array(fields[2], &buf);
defer bytes.buffer_destroy(&buf);
if !is_kind(zlib_error, E_General.OK) {
if zlib_error != E_General.OK {
ok = false; return;
}
@@ -161,7 +161,7 @@ text :: proc(c: Chunk) -> (res: Text, ok: bool) {
buf: bytes.Buffer;
zlib_error := zlib.inflate_from_byte_array(rest, &buf);
defer bytes.buffer_destroy(&buf);
if !is_kind(zlib_error, E_General.OK) {
if zlib_error != E_General.OK {
ok = false; return;
}
@@ -200,7 +200,7 @@ iccp :: proc(c: Chunk) -> (res: iCCP, ok: bool) {
// Set up ZLIB context and decompress iCCP payload
buf: bytes.Buffer;
zlib_error := zlib.inflate_from_byte_array(fields[2], &buf);
if !is_kind(zlib_error, E_General.OK) {
if zlib_error != E_General.OK {
bytes.buffer_destroy(&buf);
ok = false; return;
}
@@ -498,7 +498,7 @@ when false {
err = zlib.write_zlib_stream_from_memory(&ctx);
b: []u8;
if is_kind(err, E_General, E_General.OK) {
if err == E_General.OK {
b = ctx.out_buf[:];
} else {
return err;