<commit_before>// vim: tabstop=4 shiftwidth=4

// Copyright (c) 2010 , NetEase.com,Inc. All rights reserved.
//
// Author: <NAME> (<EMAIL>)
//
// Use, modification and distribution are subject to the "New BSD License"
// as listed at <url: http://www.opensource.org/licenses/bsd-license.php >.

package com.netease.protobuf {
	import flash.errors.*;
	import flash.utils.*;
	/**
	 * @private
	 */
	public final class WritingBuffer extends ByteArray {
		public function WritingBuffer() {
			endian = Endian.LITTLE_ENDIAN
		}
		private const slices:ByteArray = new ByteArray
		public function beginBlock():uint {
			slices.writeUnsignedInt(position)
			const beginSliceIndex:uint = slices.length
			if (beginSliceIndex % 8 != 4) {
				throw new IllegalOperationError
			}
			slices.writeDouble(0)
			slices.writeUnsignedInt(position)
			return beginSliceIndex
		}
		public function endBlock(beginSliceIndex:uint):void {
			if (slices.length % 8 != 0) {
				throw new IllegalOperationError
			}
			slices.writeUnsignedInt(position)
			slices.position = beginSliceIndex + 8
			const beginPosition:uint = slices.readUnsignedInt()
			slices.position = beginSliceIndex
			slices.writeUnsignedInt(position)
			WriteUtils.write$TYPE_UINT32(this, position - beginPosition)
			slices.writeUnsignedInt(position)
			slices.position = slices.length
			slices.writeUnsignedInt(position)
		}
		public function toNormal(output:IDataOutput):void {
			if (slices.length % 8 != 0) {
				throw new IllegalOperationError
			}
			slices.position = 0
			var begin:uint = 0
			while (slices.bytesAvailable > 0) {
				var end:uint = slices.readUnsignedInt()
				if (end > begin) {
					output.writeBytes(this, begin, end - begin)
				} else if (end < begin) {
					throw new IllegalOperationError
				}
				begin = slices.readUnsignedInt()
			}
			if (begin < length) {
				output.writeBytes(this, begin)
			}
		}
	}
}<commit_msg>用Vector实现WritingBuffer，发布的二进制版本不支持Flash Player 9。Flash Player 9需要切换成Array模式才能使用<commit_after>// vim: tabstop=4 shiftwidth=4

// Copyright (c) 2010 , NetEase.com,Inc. All rights reserved.
//
// Author: <NAME> (<EMAIL>)
//
// Use, modification and distribution are subject to the "New BSD License"
// as listed at <url: http://www.opensource.org/licenses/bsd-license.php >.

package com.netease.protobuf {
	import flash.errors.*;
	import flash.utils.*;
	/**
	 * @private
	 */
	public final class WritingBuffer extends ByteArray {
		public function WritingBuffer() {
			endian = Endian.LITTLE_ENDIAN
		}
		/*
			// for Flash Player 9
			[ArrayElementType("uint")]
			private const slices:Array = []
		/*/
			// for Flash Player 10
			private const slices:Vector.<uint> = new Vector.<uint>
		//*/
		public function beginBlock():uint {
			slices.push(position)
			const beginSliceIndex:uint = slices.length
			slices.length += 2
			slices.push(position)
			return beginSliceIndex
		}
		public function endBlock(beginSliceIndex:uint):void {
			slices.push(position)
			const beginPosition:uint = slices[beginSliceIndex + 2]
			slices[beginSliceIndex] = position
			WriteUtils.write$TYPE_UINT32(this, position - beginPosition)
			slices[beginSliceIndex + 1] = position
			slices.push(position)
		}
		public function toNormal(output:IDataOutput):void {
			var i:uint = 0
			var begin:uint = 0
			while (i < slices.length) {
				var end:uint = slices[i]
				++i
				if (end > begin) {
					output.writeBytes(this, begin, end - begin)
				} else if (end < begin) {
					throw new IllegalOperationError
				}
				begin = slices[i]
				++i
			}
			output.writeBytes(this, begin)
		}
	}
}
{'fraction_non_alphanumeric': 0.11458915595304639, 'fraction_numerical': 0.01034097261039687, 'mean_word_length': 3.4849624060150375, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7046545', 'n_tokens_mistral': 1409, 'n_tokens_neox': 1168, 'n_words': 273}