summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO.txt1
-rw-r--r--coverage/tracer.c22
2 files changed, 20 insertions, 3 deletions
diff --git a/TODO.txt b/TODO.txt
index 3b65de0c..bef11baf 100644
--- a/TODO.txt
+++ b/TODO.txt
@@ -29,6 +29,7 @@ x Tricky swapping of collector like figleaf, pycov, et al. (Don't need to do
CodeParser.raw_parse.
- If tracing, canonical_filename_cache overlaps with should_trace_cache. Skip
canonical_filename_cache. Maybe it isn't even worth it...
+- Would pre-allocating line number integers make the C tracer faster?
* Accuracy
diff --git a/coverage/tracer.c b/coverage/tracer.c
index 2ecd187a..eddbc856 100644
--- a/coverage/tracer.c
+++ b/coverage/tracer.c
@@ -243,6 +243,7 @@ Tracer_record_pair(Tracer *self, int l1, int l2)
static int
Tracer_trace(Tracer *self, PyFrameObject *frame, int what, PyObject *arg)
{
+ int ret = 0;
PyObject * filename = NULL;
PyObject * tracename = NULL;
@@ -326,7 +327,10 @@ Tracer_trace(Tracer *self, PyFrameObject *frame, int what, PyObject *arg)
STATS( self->stats.errors++; )
return -1;
}
- PyDict_SetItem(self->should_trace_cache, filename, tracename);
+ if (PyDict_SetItem(self->should_trace_cache, filename, tracename) < 0) {
+ STATS( self->stats.errors++; )
+ return -1;
+ }
}
else {
Py_INCREF(tracename);
@@ -341,8 +345,12 @@ Tracer_trace(Tracer *self, PyFrameObject *frame, int what, PyObject *arg)
STATS( self->stats.errors++; )
return -1;
}
- PyDict_SetItem(self->data, tracename, file_data);
+ ret = PyDict_SetItem(self->data, tracename, file_data);
Py_DECREF(file_data);
+ if (ret < 0) {
+ STATS( self->stats.errors++; )
+ return -1;
+ }
}
self->cur_file_data = file_data;
SHOWLOG(self->depth, frame->f_lineno, filename, "traced");
@@ -389,8 +397,16 @@ Tracer_trace(Tracer *self, PyFrameObject *frame, int what, PyObject *arg)
else {
/* Tracing lines: key is simply this_line. */
PyObject * this_line = MyInt_FromLong(frame->f_lineno);
- PyDict_SetItem(self->cur_file_data, this_line, Py_None);
+ if (this_line == NULL) {
+ STATS( self->stats.errors++; )
+ return -1;
+ }
+ ret = PyDict_SetItem(self->cur_file_data, this_line, Py_None);
Py_DECREF(this_line);
+ if (ret < 0) {
+ STATS( self->stats.errors++; )
+ return -1;
+ }
}
}
self->last_line = frame->f_lineno;