Skip to content

Commit ff2e495

Browse files
committed
Play a little code golf with the FuzzyCompare function
1 parent a6c0adb commit ff2e495

File tree

11 files changed

+18
-28
lines changed

11 files changed

+18
-28
lines changed

Library/src/main/java/dev/testify/core/processor/BitmapExtentions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright (c) 2023 ndtp
4+
* Copyright (c) 2023-2024 ndtp
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

Library/src/main/java/dev/testify/core/processor/ParallelPixelProcessor.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright (c) 2023 ndtp
4+
* Copyright (c) 2023-2024 ndtp
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -81,8 +81,6 @@ class ParallelPixelProcessor private constructor(
8181
).apply {
8282
baselineBitmap.copyPixelsToBuffer(baselineBuffer)
8383
currentBitmap.copyPixelsToBuffer(currentBuffer)
84-
baselineBitmap.recycle()
85-
currentBitmap.recycle()
8684
}
8785
}
8886

Library/src/main/java/dev/testify/core/processor/compare/FuzzyCompare.kt

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Modified work copyright (c) 2022 ndtp
4+
* Modified work copyright (c) 2022-2024 ndtp
55
* Original work copyright (c) 2019 Shopify Inc.
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -87,18 +87,10 @@ internal class FuzzyCompare(
8787
.baseline(baselineBitmap)
8888
.current(currentBitmap)
8989
.analyze { baselinePixel, currentPixel, (x, y) ->
90-
if (baselinePixel == currentPixel) {
91-
/* return */ true
92-
} else {
93-
var exclude = false
94-
for (rect in exclusionRects) {
95-
if (rect.contains(x, y)) {
96-
exclude = true
97-
break
98-
}
99-
}
100-
exclude || analyzePixelFunction(baselinePixel, currentPixel)
101-
}
90+
(baselinePixel == currentPixel) || exclusionRects.any { it.contains(x, y) } || analyzePixelFunction(
91+
baselinePixel,
92+
currentPixel
93+
)
10294
}
10395
}
10496
}

Library/src/main/java/dev/testify/core/processor/diff/HighContrastDiff.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright (c) 2023 ndtp
4+
* Copyright (c) 2023-2024 ndtp
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

Library/src/main/java/dev/testify/internal/helpers/ManifestHelpers.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright (c) 2023 ndtp
4+
* Copyright (c) 2023-2024 ndtp
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

Library/src/test/java/dev/testify/core/processor/ParallelPixelProcessorTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright (c) 2023 ndtp
4+
* Copyright (c) 2023-2024 ndtp
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

Library/src/test/java/dev/testify/core/processor/compare/FuzzyCompareTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright (c) 2023 ndtp
4+
* Copyright (c) 2023-2024 ndtp
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

Library/src/test/java/dev/testify/core/processor/compare/RegionCompareTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Modified work copyright (c) 2022 ndtp
4+
* Modified work copyright (c) 2022-2024 ndtp
55
* Original work copyright (c) 2020 Shopify Inc.
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy

Library/src/test/java/dev/testify/core/processor/diff/HighContrastDiffTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright (c) 2023 ndtp
4+
* Copyright (c) 2023-2024 ndtp
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

Plugins/Gradle/src/main/kotlin/dev/testify/TestifyExtension.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Modified work copyright (c) 2022 ndtp
4+
* Modified work copyright (c) 2022-2024 ndtp
55
* Original work copyright (c) 2019 Shopify Inc.
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy

build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ buildscript {
2424
],
2525
'colormath' : '1.4.1', // https://github.com/ajalt/colormath/releases
2626
'compose' : [ // https://developer.android.com/jetpack/androidx/releases/compose
27-
'compilerExt': '1.4.7',
28-
'core' : '1.4.3',
29-
'material' : '1.4.3',
30-
'ui' : '1.4.3',
27+
'compilerExt': '1.4.7',
28+
'core' : '1.4.3',
29+
'material' : '1.4.3',
30+
'ui' : '1.4.3',
3131
],
3232
'dokka' : '1.8.10', // https://github.com/Kotlin/dokka/releases
3333
'gson' : '2.9.0', // https://github.com/google/gson/releases

0 commit comments

Comments
 (0)