Skip to content

refactor(libcobj): minor maintainability cleanups around INDEXED file cursor#839

Draft
yutaro-sakamoto wants to merge 4 commits into
opensourcecobol:developfrom
yutaro-sakamoto:indexed-file-lock-refactor
Draft

refactor(libcobj): minor maintainability cleanups around INDEXED file cursor#839
yutaro-sakamoto wants to merge 4 commits into
opensourcecobol:developfrom
yutaro-sakamoto:indexed-file-lock-refactor

Conversation

@yutaro-sakamoto

@yutaro-sakamoto yutaro-sakamoto commented May 25, 2026

Copy link
Copy Markdown
Contributor

概要

INDEXED ファイル実装まわりの保守容易性を、ほんの少しだけ上げるための小規模なリファクタです。挙動の変更を意図したものではなく、純粋に内部の整理を目的としています。

変更内容

  • IndexedCursor の内部ヘルパーメソッド(fetchFirstRecord, fetchLastRecord, forwardNextRecord, backwardPrevRecord, fetchRecord, prev ほか)に private 修飾子を付与し、クラス外から呼ぶべきでないものを明示しました。
  • IndexedCursor.close() は本体が空のメソッドだったため削除しました。呼び出し側だった CobolIndexedFileclose_ / returnWith および private な closeCursor() ヘルパーからも、対応する呼び出しを除去しています。
  • IndexedCursor.reloadCursor()Optional.of(this) を返すだけの no-op であり、呼び出し側でも実質的にカーソル状態を再構築していなかったため削除しました。
  • CobolIndexedFile.updateWhileReading フィールドを削除しました。readNext_internal 内の唯一の読み取り箇所は直後の !cursor.isPresent() ガードと等価な分岐だけを持っており、フラグの set/reset は返り値に観測可能な影響を与えていませんでした。同等の挙動になることをロジック追跡で確認済みです。

Summary (English)

This PR contains a small set of refactors aimed at making the INDEXED file implementation slightly easier to maintain. No behavioral change is intended.

Changes

  • Adds private modifiers to internal helper methods of IndexedCursor (fetchFirstRecord, fetchLastRecord, forwardNextRecord, backwardPrevRecord, fetchRecord, prev, etc.) so that the externally-callable API surface becomes explicit.
  • Removes IndexedCursor.close(), which had an empty body. The call sites in CobolIndexedFile (close_, returnWith, and the small closeCursor() private helper that wrapped them) are removed accordingly.
  • Removes IndexedCursor.reloadCursor(), which was a no-op returning Optional.of(this); callers did not actually reconstruct cursor state with it.
  • Removes the updateWhileReading field in CobolIndexedFile. The single read site in readNext_internal was immediately followed by an equivalent !cursor.isPresent() guard, so toggling the flag had no observable effect on the return value. The collapsed control flow has been verified to be equivalent by case analysis.

yutaro-sakamoto and others added 4 commits May 25, 2026 02:15
`IndexedCursor.close()` had an empty body, so every call site
(`CobolIndexedFile.close_`, the cursor replacement path, the private
`closeCursor()` helper, and `returnWith`) was a no-op. Drop the method
along with its callers to remove dead code.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The method body was empty, so every invocation in CobolIndexedFile was
a no-op. Remove the method, the private closeCursor() helper, and all
remaining calls.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The field's set/reset were observable nowhere: the only read site was
followed by an identical `!cursor.isPresent()` guard, so toggling the
flag never affected the return value. Drop the field, its writes in
`open_` / `write_` / `delete_`, and collapse the read site to the
equivalent cursor-presence check.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant