summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Haberman <joshua@reverberate.org>2011-02-14 10:24:33 -0800
committerJoshua Haberman <joshua@reverberate.org>2011-02-14 10:24:33 -0800
commit4f9aeee6c7414bec2e1d8a9d3508dbd21f4d3394 (patch)
tree9c612f70ba57a593b7885f8e7478cb0399d2c37a
parent6117730c85e5d64239337f0e8514109054202f5a (diff)
More completely fixed the 0-key thing.
Unfortunately this degrades hash table lookup performance by about 8%, which affects the streaming benchmark for googlemessage1 by about 5%. We could get this back at the cost of some memory, but it would be nice to avoid that.
-rw-r--r--Makefile9
-rw-r--r--src/upb_def.c6
-rw-r--r--src/upb_table.c1
-rw-r--r--src/upb_table.h3
-rw-r--r--src/upbc.c1
5 files changed, 8 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index 92f1cd8..13cd4c2 100644
--- a/Makefile
+++ b/Makefile
@@ -40,7 +40,7 @@ LDLIBS=-lpthread src/libupb.a
# of the scheme we use that compiles the same source file multiple times with
# different -D options, which can include different header files.
deps: gen-deps.sh Makefile $(CORE) $(STREAM)
- @CPPFLAGS="$(CPPFLAGS)" ./gen-deps.sh $(CORE) $(STREAM)
+ @CPPFLAGS="$(CPPFLAGS)" ./gen-deps.sh $(CORE) $(STREAM) $(TOOLS)
@echo Regenerating dependencies for src/...
$(ALLSRC): perf-cppflags
@@ -68,6 +68,9 @@ STREAM= \
src/upb_msg.c \
src/upb_glue.c \
+TOOLS= \
+ src/upbc.c
+
# Parts of core that are yet to be converted.
OTHERSRC=src/upb_encoder.c src/upb_text.c
@@ -222,13 +225,13 @@ tests/t.test_vs_proto2.googlemessage2: \
tests/test_table: tests/test_table.cc
@# Includes <hash_set> which is a deprecated header.
@echo CXX $<
- $(CXX) $(CXXFLAGS) $(CPPFLAGS) -Wno-deprecated -o $@ $< $(LIBUPB)
+ @$(CXX) $(CXXFLAGS) $(CPPFLAGS) -Wno-deprecated -o $@ $< $(LIBUPB)
tests/tests: src/libupb.a
# Tools
tools: src/upbc
-tools/upbc: $(LIBUPB)
+src/upbc: $(LIBUPB)
# Benchmarks. ##################################################################
diff --git a/src/upb_def.c b/src/upb_def.c
index 879f1e8..7e962c8 100644
--- a/src/upb_def.c
+++ b/src/upb_def.c
@@ -476,12 +476,6 @@ static upb_flow_t upb_enumdef_EnumValueDescriptorProto_value(void *_b,
break;
case GOOGLE_PROTOBUF_ENUMVALUEDESCRIPTORPROTO_NUMBER_FIELDNUM:
b->number = upb_value_getint32(val);
- if (b->number == 0) {
- upb_seterr(&b->status, UPB_ERROR,
- "Enums with a value of 0 are currently broken; see "
- "http://code.google.com/p/upb/issues/detail?id=1.");
- return UPB_BREAK;
- }
b->saw_number = true;
break;
default:
diff --git a/src/upb_table.c b/src/upb_table.c
index 39b8f20..720cc62 100644
--- a/src/upb_table.c
+++ b/src/upb_table.c
@@ -129,7 +129,6 @@ static void intinsert(upb_inttable *t, upb_inttable_entry *e)
void upb_inttable_insert(upb_inttable *t, upb_inttable_entry *e)
{
- assert(e->key != 0);
if((double)(t->t.count + 1) / upb_inttable_size(t) > MAX_LOAD) {
/* Need to resize. New table of double the size, add old elements to it. */
upb_inttable new_table;
diff --git a/src/upb_table.h b/src/upb_table.h
index 1918e20..e667f0d 100644
--- a/src/upb_table.h
+++ b/src/upb_table.h
@@ -100,12 +100,11 @@ INLINE uint32_t upb_inttable_bucket(upb_inttable *t, upb_inttable_key_t k) {
* ability to optimize. */
INLINE void *upb_inttable_fastlookup(upb_inttable *t, uint32_t key,
uint32_t entry_size) {
- assert(key != 0);
uint32_t bucket = upb_inttable_bucket(t, key);
upb_inttable_entry *e;
do {
e = (upb_inttable_entry*)UPB_INDEX(t->t.entries, bucket-1, entry_size);
- if(e->key == key) return e;
+ if(e->key == key && e->has_entry) return e;
} while((bucket = e->next) != UPB_END_OF_CHAIN);
return NULL; /* Not found. */
}
diff --git a/src/upbc.c b/src/upbc.c
index a636301..62f5afd 100644
--- a/src/upbc.c
+++ b/src/upbc.c
@@ -231,6 +231,7 @@ int main(int argc, char *argv[])
free(defs);
upb_string_unref(descriptor);
upb_symtab_unref(s);
+ upb_symtab_unref(s2);
fclose(h_const_file);
return 0;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback