You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2015/09/04 21:56:23 UTC
svn commit: r1701322 - in /subversion/trunk/subversion:
include/private/svn_ra_svn_private.h libsvn_ra_svn/client.c
libsvn_ra_svn/cram.c libsvn_ra_svn/marshal.c svnserve/cyrus_auth.c
svnserve/serve.c
Author: stefan2
Date: Fri Sep 4 19:56:23 2015
New Revision: 1701322
URL: http://svn.apache.org/r1701322
Log:
Fine-tune ra_svn's item type definition: Remove a level of indirection
from the STRING union element.
This saves an extra allocation and the space for one pointer per string.
In total, this compensates the prior increase in RAM usage caused by
directly instantiating the list element.
* subversion/include/private/svn_ra_svn_private.h
(svn_ra_svn__item_t): Instantiate the string directly instead of using
a pointer.
* subversion/libsvn_ra_svn/client.c
(ra_svn_get_file): Update all references to the string union element.
* subversion/libsvn_ra_svn/cram.c
(svn_ra_svn_cram_server): Same.
* subversion/svnserve/cyrus_auth.c
(try_auth): Same.
* subversion/svnserve/serve.c
(add_lock_tokens,
unlock_paths,
get_mergeinfo,
log_cmd): Same.
* subversion/libsvn_ra_svn/marshal.c
(svn_ra_svn__to_public_item,
svn_ra_svn__to_private_item): Same.
(read_string): Don't allocate the string struct itself but only the
string data.
(vparse_tuple,
svn_ra_svn__read_string,
svn_ra_svn__read_cstring): Update all references to the string element.
Modified:
subversion/trunk/subversion/include/private/svn_ra_svn_private.h
subversion/trunk/subversion/libsvn_ra_svn/client.c
subversion/trunk/subversion/libsvn_ra_svn/cram.c
subversion/trunk/subversion/libsvn_ra_svn/marshal.c
subversion/trunk/subversion/svnserve/cyrus_auth.c
subversion/trunk/subversion/svnserve/serve.c
Modified: subversion/trunk/subversion/include/private/svn_ra_svn_private.h
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_ra_svn_private.h?rev=1701322&r1=1701321&r2=1701322&view=diff
==============================================================================
--- subversion/trunk/subversion/include/private/svn_ra_svn_private.h (original)
+++ subversion/trunk/subversion/include/private/svn_ra_svn_private.h Fri Sep 4 19:56:23 2015
@@ -60,7 +60,7 @@ typedef struct svn_ra_svn__item_t
/** Variant data. */
union {
apr_uint64_t number;
- svn_string_t *string;
+ svn_string_t string;
const char *word;
svn_ra_svn__list_t list;
} u;
Modified: subversion/trunk/subversion/libsvn_ra_svn/client.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/client.c?rev=1701322&r1=1701321&r2=1701322&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/client.c (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/client.c Fri Sep 4 19:56:23 2015
@@ -1300,15 +1300,15 @@ static svn_error_t *ra_svn_get_file(svn_
if (item->kind != SVN_RA_SVN_STRING)
return svn_error_create(SVN_ERR_RA_SVN_MALFORMED_DATA, NULL,
_("Non-string as part of file contents"));
- if (item->u.string->len == 0)
+ if (item->u.string.len == 0)
break;
if (expected_checksum)
- SVN_ERR(svn_checksum_update(checksum_ctx, item->u.string->data,
- item->u.string->len));
+ SVN_ERR(svn_checksum_update(checksum_ctx, item->u.string.data,
+ item->u.string.len));
- SVN_ERR(svn_stream_write(stream, item->u.string->data,
- &item->u.string->len));
+ SVN_ERR(svn_stream_write(stream, item->u.string.data,
+ &item->u.string.len));
}
svn_pool_destroy(iterpool);
@@ -2155,7 +2155,7 @@ static svn_error_t *ra_svn_get_file_revs
if (item->kind != SVN_RA_SVN_STRING)
return svn_error_create(SVN_ERR_RA_SVN_MALFORMED_DATA, NULL,
_("Text delta chunk not a string"));
- has_txdelta = item->u.string->len > 0;
+ has_txdelta = item->u.string.len > 0;
SVN_ERR(handler(handler_baton, p, rev, rev_props, merged_rev,
has_txdelta ? &d_handler : NULL, &d_baton,
@@ -2171,13 +2171,13 @@ static svn_error_t *ra_svn_get_file_revs
rev_pool);
else
stream = NULL;
- while (item->u.string->len > 0)
+ while (item->u.string.len > 0)
{
apr_size_t size;
- size = item->u.string->len;
+ size = item->u.string.len;
if (stream)
- SVN_ERR(svn_stream_write(stream, item->u.string->data, &size));
+ SVN_ERR(svn_stream_write(stream, item->u.string.data, &size));
svn_pool_clear(chunk_pool);
SVN_ERR(svn_ra_svn__read_item(sess_baton->conn, chunk_pool,
Modified: subversion/trunk/subversion/libsvn_ra_svn/cram.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/cram.c?rev=1701322&r1=1701321&r2=1701322&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/cram.c (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/cram.c Fri Sep 4 19:56:23 2015
@@ -160,7 +160,7 @@ svn_error_t *svn_ra_svn_cram_server(svn_
SVN_ERR(svn_ra_svn__read_item(conn, pool, &item));
if (item->kind != SVN_RA_SVN_STRING) /* Very wrong; don't report failure */
return SVN_NO_ERROR;
- resp = item->u.string;
+ resp = &item->u.string;
sep = strrchr(resp->data, ' ');
if (!sep || resp->len - (sep + 1 - resp->data) != APR_MD5_DIGESTSIZE * 2
|| !hex_decode(cdigest, sep + 1))
Modified: subversion/trunk/subversion/libsvn_ra_svn/marshal.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_ra_svn/marshal.c?rev=1701322&r1=1701321&r2=1701322&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_ra_svn/marshal.c (original)
+++ subversion/trunk/subversion/libsvn_ra_svn/marshal.c Fri Sep 4 19:56:23 2015
@@ -91,7 +91,7 @@ svn_ra_svn__to_public_item(svn_ra_svn_it
switch (source->kind)
{
case SVN_RA_SVN_STRING:
- target->u.string = svn_string_dup(source->u.string, result_pool);
+ target->u.string = svn_string_dup(&source->u.string, result_pool);
break;
case SVN_RA_SVN_NUMBER:
target->u.number = source->u.number;
@@ -134,7 +134,7 @@ svn_ra_svn__to_private_item(svn_ra_svn__
switch (source->kind)
{
case SVN_RA_SVN_STRING:
- target->u.string = svn_string_dup(source->u.string, result_pool);
+ target->u.string = *source->u.string;
break;
case SVN_RA_SVN_NUMBER:
target->u.number = source->u.number;
@@ -1145,7 +1145,8 @@ static svn_error_t *read_string(svn_ra_s
if (conn->read_ptr + len <= conn->read_end)
{
item->kind = SVN_RA_SVN_STRING;
- item->u.string = svn_string_ncreate(conn->read_ptr, len, pool);
+ item->u.string.data = apr_pstrmemdup(pool, conn->read_ptr, len);
+ item->u.string.len = len;
conn->read_ptr += len;
}
else
@@ -1186,7 +1187,8 @@ static svn_error_t *read_string(svn_ra_s
/* Return the string properly wrapped into an RA_SVN item. */
item->kind = SVN_RA_SVN_STRING;
- item->u.string = svn_stringbuf__morph_into_string(stringbuf);
+ item->u.string.data = stringbuf->data;
+ item->u.string.len = stringbuf->len;
}
return SVN_NO_ERROR;
@@ -1514,9 +1516,9 @@ vparse_tuple(const svn_ra_svn__list_t *i
SVN_ERR(vparse_tuple(&elt->u.list, pool, fmt, ap));
}
else if (**fmt == 'c' && elt->kind == SVN_RA_SVN_STRING)
- *va_arg(*ap, const char **) = elt->u.string->data;
+ *va_arg(*ap, const char **) = elt->u.string.data;
else if (**fmt == 's' && elt->kind == SVN_RA_SVN_STRING)
- *va_arg(*ap, svn_string_t **) = elt->u.string;
+ *va_arg(*ap, svn_string_t **) = &elt->u.string;
else if (**fmt == 'w' && elt->kind == SVN_RA_SVN_WORD)
*va_arg(*ap, const char **) = elt->u.word;
else if (**fmt == 'b' && elt->kind == SVN_RA_SVN_WORD)
@@ -2829,7 +2831,7 @@ svn_ra_svn__read_string(const svn_ra_svn
{
svn_ra_svn__item_t *elt = &SVN_RA_SVN__LIST_ITEM(items, idx);
CHECK_PROTOCOL_COND(elt->kind == SVN_RA_SVN_STRING);
- *result = elt->u.string;
+ *result = &elt->u.string;
return SVN_NO_ERROR;
}
@@ -2843,7 +2845,7 @@ svn_ra_svn__read_cstring(const svn_ra_sv
{
svn_ra_svn__item_t *elt = &SVN_RA_SVN__LIST_ITEM(items, idx);
CHECK_PROTOCOL_COND(elt->kind == SVN_RA_SVN_STRING);
- *result = elt->u.string->data;
+ *result = elt->u.string.data;
return SVN_NO_ERROR;
}
Modified: subversion/trunk/subversion/svnserve/cyrus_auth.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/cyrus_auth.c?rev=1701322&r1=1701321&r2=1701322&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/cyrus_auth.c (original)
+++ subversion/trunk/subversion/svnserve/cyrus_auth.c Fri Sep 4 19:56:23 2015
@@ -213,7 +213,7 @@ static svn_error_t *try_auth(svn_ra_svn_
if (item->kind != SVN_RA_SVN_STRING)
return SVN_NO_ERROR;
- in = item->u.string;
+ in = &item->u.string;
if (use_base64)
in = svn_base64_decode_string(in, pool);
Modified: subversion/trunk/subversion/svnserve/serve.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/svnserve/serve.c?rev=1701322&r1=1701321&r2=1701322&view=diff
==============================================================================
--- subversion/trunk/subversion/svnserve/serve.c (original)
+++ subversion/trunk/subversion/svnserve/serve.c Fri Sep 4 19:56:23 2015
@@ -1353,7 +1353,7 @@ add_lock_tokens(const svn_ra_svn__list_t
return svn_error_create(SVN_ERR_RA_SVN_MALFORMED_DATA, NULL,
"Lock token isn't a string");
- path = path_item->u.string->data;
+ path = path_item->u.string.data;
full_path = svn_fspath__join(sb->repository->fs_path->data,
svn_relpath_canonicalize(path, pool),
pool);
@@ -1362,7 +1362,7 @@ add_lock_tokens(const svn_ra_svn__list_t
return error_create_and_log(SVN_ERR_RA_NOT_AUTHORIZED, NULL, NULL,
sb);
- token = token_item->u.string->data;
+ token = token_item->u.string.data;
SVN_ERR(svn_fs_access_add_lock_token2(fs_access, path, token));
}
@@ -1405,11 +1405,11 @@ unlock_paths(const svn_ra_svn__list_t *l
path_item = &SVN_RA_SVN__LIST_ITEM(&item->u.list, 0);
token_item = &SVN_RA_SVN__LIST_ITEM(&item->u.list, 1);
- path = path_item->u.string->data;
+ path = path_item->u.string.data;
full_path = svn_fspath__join(sb->repository->fs_path->data,
svn_relpath_canonicalize(path, subpool),
subpool);
- token = token_item->u.string->data;
+ token = token_item->u.string.data;
svn_hash_sets(targets, full_path, token);
}
@@ -2127,7 +2127,7 @@ get_mergeinfo(svn_ra_svn_conn_t *conn,
if (item->kind != SVN_RA_SVN_STRING)
return svn_error_create(SVN_ERR_RA_SVN_MALFORMED_DATA, NULL,
_("Path is not a string"));
- full_path = svn_relpath_canonicalize(item->u.string->data, pool);
+ full_path = svn_relpath_canonicalize(item->u.string.data, pool);
full_path = svn_fspath__join(b->repository->fs_path->data, full_path, pool);
APR_ARRAY_PUSH(canonical_paths, const char *) = full_path;
}
@@ -2301,7 +2301,7 @@ log_cmd(svn_ra_svn_conn_t *conn,
if (elt->kind != SVN_RA_SVN_STRING)
return svn_error_create(SVN_ERR_RA_SVN_MALFORMED_DATA, NULL,
_("Log revprop entry not a string"));
- APR_ARRAY_PUSH(revprops, const char *) = elt->u.string->data;
+ APR_ARRAY_PUSH(revprops, const char *) = elt->u.string.data;
}
}
else
@@ -2323,7 +2323,7 @@ log_cmd(svn_ra_svn_conn_t *conn,
if (elt->kind != SVN_RA_SVN_STRING)
return svn_error_create(SVN_ERR_RA_SVN_MALFORMED_DATA, NULL,
_("Log path entry not a string"));
- full_path = svn_relpath_canonicalize(elt->u.string->data, pool),
+ full_path = svn_relpath_canonicalize(elt->u.string.data, pool),
full_path = svn_fspath__join(b->repository->fs_path->data, full_path,
pool);
APR_ARRAY_PUSH(full_paths, const char *) = full_path;