Return-Path: X-Original-To: apmail-subversion-commits-archive@minotaur.apache.org Delivered-To: apmail-subversion-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 75A1CE85F for ; Fri, 1 Mar 2013 22:22:45 +0000 (UTC) Received: (qmail 17511 invoked by uid 500); 1 Mar 2013 22:22:45 -0000 Delivered-To: apmail-subversion-commits-archive@subversion.apache.org Received: (qmail 17483 invoked by uid 500); 1 Mar 2013 22:22:45 -0000 Mailing-List: contact commits-help@subversion.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@subversion.apache.org Delivered-To: mailing list commits@subversion.apache.org Received: (qmail 17476 invoked by uid 99); 1 Mar 2013 22:22:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Mar 2013 22:22:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Mar 2013 22:22:44 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 05A0223888EA; Fri, 1 Mar 2013 22:22:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1451738 - /subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/string_table.c Date: Fri, 01 Mar 2013 22:22:24 -0000 To: commits@subversion.apache.org From: stefan2@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130301222225.05A0223888EA@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: stefan2 Date: Fri Mar 1 22:22:24 2013 New Revision: 1451738 URL: http://svn.apache.org/r1451738 Log: On the fsfs-format7 branch: Fix bugs in the string table implemenation discovered by our new unit tests. * subversion/libsvn_fs_fs/string_table.c (insert_string): buggy remaining table capacity calculation (svn_fs_fs__string_table_builder_add): the default match length is 0 (create_table): pick delta base from tree order not insert order (table_copy_string): handle an edge case (svn_fs_fs__string_table_get): result got lost Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/string_table.c Modified: subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/string_table.c URL: http://svn.apache.org/viewvc/subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/string_table.c?rev=1451738&r1=1451737&r2=1451738&view=diff ============================================================================== --- subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/string_table.c (original) +++ subversion/branches/fsfs-format7/subversion/libsvn_fs_fs/string_table.c Fri Mar 1 22:22:24 2013 @@ -205,9 +205,13 @@ insert_string(builder_table_t *table, to_insert->next_match_len = match_length(¤t->string, &to_insert->string); current->previous_match_len = to_insert->next_match_len; - - table->max_data_size -= MIN(to_insert->previous_match_len, - to_insert->next_match_len); + + table->max_data_size -= to_insert->string.len; + if (to_insert->previous == NULL) + table->max_data_size += to_insert->next_match_len; + else + table->max_data_size += MIN(to_insert->previous_match_len, + to_insert->next_match_len); return to_insert->position; } @@ -242,8 +246,12 @@ insert_string(builder_table_t *table, = match_length(¤t->string, &to_insert->string); current->next_match_len = to_insert->previous_match_len; - table->max_data_size -= MIN(to_insert->previous_match_len, - to_insert->next_match_len); + table->max_data_size -= to_insert->string.len; + if (to_insert->next == NULL) + table->max_data_size += to_insert->previous_match_len; + else + table->max_data_size += MIN(to_insert->previous_match_len, + to_insert->next_match_len); return to_insert->position; } @@ -295,8 +303,8 @@ svn_fs_fs__string_table_builder_add(stri builder_string_t *item = apr_pcalloc(builder->pool, sizeof(*item)); item->string.data = string; item->string.len = len; - item->previous_match_len = APR_SIZE_MAX; - item->next_match_len = APR_SIZE_MAX; + item->previous_match_len = 0; + item->next_match_len = 0; if ( table->long_strings->nelts == MAX_STRINGS_PER_TABLE || table->max_data_size < len) @@ -349,13 +357,8 @@ create_table(string_sub_table_t *target, string_header_t *tail_match; apr_size_t head_length = string->previous_match_len; - int base = i - 1; - if (head_length) - while ( base >= 0 - && target->short_strings[i].head_length >= head_length) - --base; - - entry->head_string = (apr_uint16_t)base; + entry->head_string + = (apr_uint16_t)(head_length ? string->previous->position : 0); entry->head_length = (apr_uint16_t)head_length; entry->tail_length = (apr_uint16_t)(string->string.len - entry->head_length); @@ -418,10 +421,14 @@ table_copy_string(char *buffer, while (to_copy) { - memcpy(buffer + header->head_length, - table->data + header->tail_start, - len - header->head_length); - to_copy = header->head_length; + if (header->head_length < to_copy) + { + memcpy(buffer + header->head_length, + table->data + header->tail_start, + to_copy - header->head_length); + to_copy = header->head_length; + } + header = &table->short_strings[header->head_string]; } @@ -455,6 +462,8 @@ svn_fs_fs__string_table_get(const string apr_size_t len = header->head_length + header->tail_length + 1; char *result = apr_palloc(pool, len); table_copy_string(result, len, sub_table, header); + + return result; } } }