<commit_before>//
//  BRScrollerUtilities.c
//  BRScroller
//
//  Created by Matt on 7/11/13.
//  Copyright (c) 2013 Blue Rocket. Distributable under the terms of the Apache License, Version 2.0.
//

#include "BRScrollerUtilities.h"

#if !defined(MIN)
	#define MIN(A,B)	((A) < (B) ? (A) : (B))
#endif

inline bool BRFloatsAreEqual(CGFloat a, CGFloat b) {
	const CGFloat d = a - b;
	return (d < 0 ? -d : d) < 1e-4;
}

inline CGSize BRAspectSizeToFit(CGSize aSize, CGSize maxSize) {
	CGFloat scale = 1.0;
	if ( aSize.width > 0.0 && aSize.height > 0.0 ) {
		CGFloat dw = maxSize.width / aSize.width;
		CGFloat dh = maxSize.height / aSize.height;
		scale = dw < dh ? dw : dh;
	}
	return CGSizeMake(MIN(floorf(maxSize.width), ceilf(aSize.width * scale)),
					  MIN(floorf(maxSize.height), ceilf(aSize.height * scale)));
}<commit_msg>Fix includes to just what is needed.<commit_after>//
//  BRScrollerUtilities.c
//  BRScroller
//
//  Created by Matt on 7/11/13.
//  Copyright (c) 2013 Blue Rocket. Distributable under the terms of the Apache License, Version 2.0.
//

#include "BRScrollerUtilities.h"

#include <math.h>
#include <sys/param.h>

inline bool BRFloatsAreEqual(CGFloat a, CGFloat b) {
	const CGFloat d = a - b;
	return (d < 0 ? -d : d) < 1e-4;
}

inline CGSize BRAspectSizeToFit(CGSize aSize, CGSize maxSize) {
	CGFloat scale = 1.0;
	if ( aSize.width > 0.0 && aSize.height > 0.0 ) {
		CGFloat dw = maxSize.width / aSize.width;
		CGFloat dh = maxSize.height / aSize.height;
		scale = dw < dh ? dw : dh;
	}
	return CGSizeMake(MIN(floorf(maxSize.width), ceilf(aSize.width * scale)),
					  MIN(floorf(maxSize.height), ceilf(aSize.height * scale)));
}
{'fraction_non_alphanumeric': 0.1486404833836858, 'fraction_numerical': 0.02416918429003021, 'mean_word_length': 3.357894736842105, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2246831', 'n_tokens_mistral': 706, 'n_tokens_neox': 652, 'n_words': 171}