ObjFW  Diff

Differences From Artifact [a322670b7a]:

To Artifact [4d6e30d967]:


40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

- (instancetype)initWithType: (int8_t)type
			data: (OFData *)data
{
	self = [super init];

	@try {
		if (data == nil || [data itemSize] != 1)
			@throw [OFInvalidArgumentException exception];

		_type = type;
		_data = [data copy];
	} @catch (id e) {
		[self release];
		@throw e;







|







40
41
42
43
44
45
46
47
48
49
50
51
52
53
54

- (instancetype)initWithType: (int8_t)type
			data: (OFData *)data
{
	self = [super init];

	@try {
		if (data == nil || data.itemSize != 1)
			@throw [OFInvalidArgumentException exception];

		_type = type;
		_data = [data copy];
	} @catch (id e) {
		[self release];
		@throw e;
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
	[super dealloc];
}

- (OFData *)messagePackRepresentation
{
	OFMutableData *ret;
	uint8_t prefix;
	size_t count = [_data count];

	if (count == 1) {
		ret = [OFMutableData dataWithCapacity: 3];

		prefix = 0xD4;
		[ret addItem: &prefix];








|







64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
	[super dealloc];
}

- (OFData *)messagePackRepresentation
{
	OFMutableData *ret;
	uint8_t prefix;
	size_t count = _data.count;

	if (count == 1) {
		ret = [OFMutableData dataWithCapacity: 3];

		prefix = 0xD4;
		[ret addItem: &prefix];

141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
		length = OF_BSWAP32_IF_LE((uint32_t)count);
		[ret addItems: &length
			count: 4];

		[ret addItem: &_type];
	}

	[ret addItems: [_data items]
		count: [_data count]];

	[ret makeImmutable];

	return ret;
}

- (OFString *)description







|
|







141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
		length = OF_BSWAP32_IF_LE((uint32_t)count);
		[ret addItems: &length
			count: 4];

		[ret addItem: &_type];
	}

	[ret addItems: _data.items
		count: _data.count];

	[ret makeImmutable];

	return ret;
}

- (OFString *)description
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
- (uint32_t)hash
{
	uint32_t hash;

	OF_HASH_INIT(hash);

	OF_HASH_ADD(hash, (uint8_t)_type);
	OF_HASH_ADD_HASH(hash, [_data hash]);

	OF_HASH_FINALIZE(hash);

	return hash;
}

- (id)copy
{
	return [self retain];
}
@end







|











180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
- (uint32_t)hash
{
	uint32_t hash;

	OF_HASH_INIT(hash);

	OF_HASH_ADD(hash, (uint8_t)_type);
	OF_HASH_ADD_HASH(hash, _data.hash);

	OF_HASH_FINALIZE(hash);

	return hash;
}

- (id)copy
{
	return [self retain];
}
@end