~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_btree_serializer_c.pyx

  • Committer: Matt Nordhoff
  • Date: 2009-06-23 05:12:07 UTC
  • mto: This revision was merged to the branch mainline in revision 4474.
  • Revision ID: mnordhoff@mattnordhoff.com-20090623051207-fksdtbzkwtnrw9dd
Update _add_text docstrings that still referred to add_text.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
41
41
    int PyString_AsStringAndSize_ptr(PyObject *, char **buf, Py_ssize_t *len)
42
42
    void PyString_InternInPlace(PyObject **)
43
43
    int PyTuple_CheckExact(object t)
44
 
    object PyTuple_New(Py_ssize_t n_entries)
45
 
    void PyTuple_SET_ITEM(object, Py_ssize_t offset, object) # steals the ref
46
44
    Py_ssize_t PyTuple_GET_SIZE(object t)
47
45
    PyObject *PyTuple_GET_ITEM_ptr_object "PyTuple_GET_ITEM" (object tpl, int index)
48
 
    void Py_INCREF(object)
49
46
    void Py_DECREF_ptr "Py_DECREF" (PyObject *)
50
47
 
51
48
cdef extern from "string.h":
143
140
        cdef char *temp_ptr
144
141
        cdef int loop_counter
145
142
        # keys are tuples
146
 
        key = PyTuple_New(self.key_length)
147
 
        for loop_counter from 0 <= loop_counter < self.key_length:
 
143
        loop_counter = 0
 
144
        key_segments = []
 
145
        while loop_counter < self.key_length:
 
146
            loop_counter = loop_counter + 1
148
147
            # grab a key segment
149
148
            temp_ptr = <char*>memchr(self._start, c'\0', last - self._start)
150
149
            if temp_ptr == NULL:
151
 
                if loop_counter + 1 == self.key_length:
 
150
                if loop_counter == self.key_length:
152
151
                    # capture to last
153
152
                    temp_ptr = last
154
153
                else:
165
164
                                                         temp_ptr - self._start)
166
165
            # advance our pointer
167
166
            self._start = temp_ptr + 1
168
 
            Py_INCREF(key_element)
169
 
            PyTuple_SET_ITEM(key, loop_counter, key_element)
170
 
        return key
 
167
            PyList_Append(key_segments, key_element)
 
168
        return tuple(key_segments)
171
169
 
172
170
    cdef int process_line(self) except -1:
173
171
        """Process a line in the bytes."""