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 903F8922F for ; Mon, 7 May 2012 17:48:40 +0000 (UTC) Received: (qmail 43856 invoked by uid 500); 7 May 2012 17:48:40 -0000 Delivered-To: apmail-subversion-commits-archive@subversion.apache.org Received: (qmail 43829 invoked by uid 500); 7 May 2012 17:48:40 -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 43822 invoked by uid 99); 7 May 2012 17:48:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 May 2012 17:48:40 +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; Mon, 07 May 2012 17:48:37 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id B698523889E3; Mon, 7 May 2012 17:48:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1335152 - /subversion/trunk/subversion/libsvn_delta/text_delta.c Date: Mon, 07 May 2012 17:48:16 -0000 To: commits@subversion.apache.org From: cmpilato@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120507174816.B698523889E3@eris.apache.org> Author: cmpilato Date: Mon May 7 17:48:16 2012 New Revision: 1335152 URL: http://svn.apache.org/viewvc?rev=1335152&view=rev Log: * subversion/libsvn_delta/text_delta.c (svn_txdelta_send_stream): Finish an old TODO item about doing straight window generation here instead of firing up the diff machinery just to diff aagainst the empty stream. Suggested by: gstein Modified: subversion/trunk/subversion/libsvn_delta/text_delta.c Modified: subversion/trunk/subversion/libsvn_delta/text_delta.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_delta/text_delta.c?rev=1335152&r1=1335151&r2=1335152&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_delta/text_delta.c (original) +++ subversion/trunk/subversion/libsvn_delta/text_delta.c Mon May 7 17:48:16 2012 @@ -904,29 +904,54 @@ svn_error_t *svn_txdelta_send_stream(svn unsigned char *digest, apr_pool_t *pool) { - svn_txdelta_stream_t *txstream; - svn_error_t *err; + svn_txdelta_window_t delta_window = { 0 }; + svn_txdelta_op_t delta_op; + svn_string_t window_data; + char read_buf[SVN__STREAM_CHUNK_SIZE + 1]; + svn_checksum_ctx_t *md5_checksum_ctx; - /* ### this is a hack. we should simply read from the stream, construct - ### some windows, and pass those to the handler. there isn't any reason - ### to crank up a full "diff" algorithm just to copy a stream. - ### - ### will fix RSN. */ - - /* Create a delta stream which converts an *empty* bytestream into the - target bytestream. */ - svn_txdelta(&txstream, svn_stream_empty(pool), stream, pool); - err = svn_txdelta_send_txstream(txstream, handler, handler_baton, pool); + if (digest) + md5_checksum_ctx = svn_checksum_ctx_create(svn_checksum_md5, pool); - if (digest && (! err)) + while (1) { - const unsigned char *result_md5; - result_md5 = svn_txdelta_md5_digest(txstream); - /* Since err is null, result_md5 "cannot" be null. */ - memcpy(digest, result_md5, APR_MD5_DIGESTSIZE); + apr_size_t read_len = SVN__STREAM_CHUNK_SIZE; + + SVN_ERR(svn_stream_read(stream, read_buf, &read_len)); + if (read_len == 0) + break; + + window_data.data = read_buf; + window_data.len = read_len; + + delta_op.action_code = svn_txdelta_new; + delta_op.offset = 0; + delta_op.length = read_len; + + delta_window.tview_len = read_len; + delta_window.num_ops = 1; + delta_window.ops = &delta_op; + delta_window.new_data = &window_data; + + SVN_ERR(handler(&delta_window, handler_baton)); + + if (digest) + SVN_ERR(svn_checksum_update(md5_checksum_ctx, read_buf, read_len)); + + if (read_len < SVN__STREAM_CHUNK_SIZE) + break; } + SVN_ERR(handler(NULL, handler_baton)); - return err; + if (digest) + { + svn_checksum_t *md5_checksum; + + SVN_ERR(svn_checksum_final(&md5_checksum, md5_checksum_ctx, pool)); + memcpy(digest, md5_checksum->digest, APR_MD5_DIGESTSIZE); + } + + return SVN_NO_ERROR; } svn_error_t *svn_txdelta_send_txstream(svn_txdelta_stream_t *txstream,