Skip to content

Commit

Permalink
Drop cruft in db code brought in by 1.8x.
Browse files Browse the repository at this point in the history
We don't allocate memory to receive data from db, so the cruft left
was only accessing db twice for lone lines.

Also clear the influenced comments.
  • Loading branch information
lichray committed Apr 3, 2015
1 parent 31fc24d commit 2c1d2dc
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions common/line.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "config.h"

#ifndef lint
static const char sccsid[] = "$Id: line.c,v 10.26 2011/08/12 12:36:41 zy Exp $";
static const char sccsid[] = "$Id: line.c,v 10.27 2015/04/03 02:47:59 zy Exp $";
#endif /* not lint */

#include <sys/types.h>
Expand Down Expand Up @@ -92,7 +92,6 @@ db_get(
recno_t l1, l2;
CHAR_T *wp;
size_t wlen;
size_t nlen;

/*
* The underlying recno stuff handles zero by returning NULL, but
Expand Down Expand Up @@ -152,8 +151,6 @@ db_get(
ep->c_lno = OOBLNO;

nocache:
nlen = 1024;
retry:
/* Get the line from the underlying database. */
key.data = &lno;
key.size = sizeof(lno);
Expand All @@ -169,11 +166,6 @@ err3: if (lenp != NULL)
if (pp != NULL)
*pp = NULL;
return (1);
case 0:
if (data.size > nlen) {
nlen = data.size;
goto retry;
}
}

if (FILE2INT(sp, data.data, data.size, wp, wlen)) {
Expand Down Expand Up @@ -544,8 +536,6 @@ db_last(
case 1:
*lnop = 0;
return (0);
case 0:
;
}

memcpy(&lno, key.data, sizeof(lno));
Expand Down Expand Up @@ -595,7 +585,6 @@ db_rget(
key.data = &lno;
key.size = sizeof(lno);
if (ep->db->get(ep->db, &key, &data, 0))
/* We do not report error, and do not ensure the size! */
return (1);

if (lenp != NULL)
Expand Down Expand Up @@ -624,14 +613,13 @@ db_rset(
/* Check for no underlying file. */
if ((ep = sp->ep) == NULL)
return (1);

/* Update file. */
key.data = &lno;
key.size = sizeof(lno);
data.data = p;
data.size = len;
if (ep->db->put(ep->db, &key, &data, 0) == -1)
/* We do not report error, and do not ensure the size! */
return (1);

return (0);
Expand Down

0 comments on commit 2c1d2dc

Please sign in to comment.