Repository navigation
コアを netstandard2.0 と net8.0 のマルチターゲットにし、net8.0 では Span<T> を使う - #11
Merged
Merged
Conversation
- net8.0 では、住所照合の正規化をスタック上で行い、CSV の読み込みで使う列だけを文字列にする - 住所の分割を都道府県名・市区町村名・町域名の順の照合に変え、候補文字列を作らないようにした(両方のビルド) - 郵便番号のチェックを LINQ・正規表現を使わないループにした(両方のビルド) - テストでコアのビルドを切り替えられるようにした(dotnet test -p:CoreTargetFramework=netstandard2.0) - README と CLAUDE.md を更新 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HNb8H3ydQTR8dWU8d28osE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
コアのターゲットを
netstandard2.0とnet8.0の 2 つにし、#if NET8_0_OR_GREATERでSpan<T>を使う処理を切り替えました。あわせて、両方のビルドに効く改善も入れています。変更内容
net8.0版だけ(Spanを使う)stackalloc)で正規化して比べる。Range)だけ求め、使う列だけを文字列にする。両方のビルド共通
Select・string.Join・Replace・正規表現をやめ、1 回の走査で 7 桁を確かめるループにした(Spanなしで十分なため#ifは使っていない)。#ifは、AddressMatcherの 2 メソッド、BarCode.WriteKanjiNumber、CSV の列を扱うCsvFields構造体、読み込みのループの中だけに閉じ込めました。漢数字の計算や 1 文字ごとの正規化は、両方のビルドで共通のメソッドを使っています。コアにSystem.Memoryなどの依存は追加していません。計測結果(実データ、10 万件、1 件あたり)
net8.0版Spanの上乗せは、分割で約 550B、読み込みで約 80MB の割り当て削減。テスト
dotnet test(net8.0版)とdotnet test -p:CoreTargetFramework=netstandard2.0の両方で 238 件すべて成功。TargetFrameworkTests)を追加。正規化のループは
StringBuilder版とSpan版の 2 通りになったため、両方のビルドでのテストが欠かせません。この後の GitHub Actions で、両方を自動でテストするようにします。🤖 Generated with Claude Code
https://claude.ai/code/session_01HNb8H3ydQTR8dWU8d28osE