From dfe7d3a3749ff1cdb55d839e3dbfda46b8b2ee72 Mon Sep 17 00:00:00 2001 From: Bo Yang Date: Wed, 7 Mar 2018 21:13:32 +0000 Subject: [PATCH] swap condition branches to remove negation --- upb/encode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/upb/encode.c b/upb/encode.c index 67678fe63b..abcf17c440 100644 --- a/upb/encode.c +++ b/upb/encode.c @@ -360,12 +360,12 @@ bool upb_encode_message(upb_encstate* e, const char *msg, CHK(upb_encode_array(e, msg + f->offset, m, f)); } else { if (upb_encode_hasscalarfield(msg, m, f)) { - if (f->oneof_index != UPB_NOT_IN_ONEOF) { + if (f->oneof_index == UPB_NOT_IN_ONEOF) { + CHK(upb_encode_scalarfield(e, msg + f->offset, m, f, !m->is_proto2)); + } else { const upb_msglayout_oneofinit_v1 *o = &m->oneofs[f->oneof_index]; CHK(upb_encode_scalarfield(e, msg + o->data_offset, m, f, !m->is_proto2)); - } else { - CHK(upb_encode_scalarfield(e, msg + f->offset, m, f, !m->is_proto2)); } } }