Skip to content

Commit 97db7cc

Browse files
committed
refactor: refine UI play logic, accessibility, and thread-safe implementation refinements
1 parent 3487276 commit 97db7cc

4 files changed

Lines changed: 28 additions & 16 deletions

File tree

  • Algorithm/Other/leetcode/83. Remove Duplicates from Sorted List/Claude 4.6 extended
  • JavaScript/2627. Debounce/Claude Code Sonnet 4.5 extended
  • public/Algorithm/Other/leetcode/83. Remove Duplicates from Sorted List/Claude 4.6 extended

Algorithm/Other/leetcode/83. Remove Duplicates from Sorted List/Claude 4.6 extended/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
- [Overview](#overview)
66
- [Algorithm](#algorithm)
7-
- [アルゴリズム要点 TL;DR](#tldr)
8-
- [図解](#figures)
9-
- [正しさのスケッチ](#correctness)
10-
- [FAQ](#faq)
7+
- [アルゴリズム要点 TL;DR](#tldr)
8+
- [図解](#figures)
9+
- [正しさのスケッチ](#correctness)
10+
- [FAQ](#faq)
1111
- [Complexity](#complexity)
1212
- [Implementation](#implementation)
13-
- [Python 実装](#impl)
14-
- [エッジケースと検証観点](#edgecases)
13+
- [Python 実装](#impl)
14+
- [エッジケースと検証観点](#edgecases)
1515
- [Optimization](#optimization)
16-
- [CPython 最適化ポイント](#cpython)
16+
- [CPython 最適化ポイント](#cpython)
1717

1818
---
1919

Algorithm/Other/leetcode/83. Remove Duplicates from Sorted List/Claude 4.6 extended/README_React.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,12 @@ <h3 className="mt-0 mb-3 text-teal-800 text-base font-bold outfit">
997997
<button
998998
type="button"
999999
className="px-4 py-2 rounded-xl font-semibold text-white transition disabled:opacity-50 shadow hover:-translate-y-0.5 bg-[linear-gradient(135deg,#10b981,#059669)] text-sm"
1000-
onClick={() => setIsPlaying(true)}
1000+
onClick={() => {
1001+
if (activeStep === stepsData.length) {
1002+
setActiveStep(1);
1003+
}
1004+
setIsPlaying(true);
1005+
}}
10011006
disabled={isPlaying}
10021007
>
10031008
▶ Play

JavaScript/2627. Debounce/Claude Code Sonnet 4.5 extended/README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ if __name__ == "__main__":
282282
```python
283283
# asyncio版(参考)
284284
import asyncio
285+
import inspect
285286
from typing import Callable, Coroutine, Any
286287

287288
def debounce_async(fn: Callable, t: float) -> Callable[..., Coroutine[Any, Any, None]]:
@@ -298,7 +299,7 @@ def debounce_async(fn: Callable, t: float) -> Callable[..., Coroutine[Any, Any,
298299
async def delayed():
299300
await asyncio.sleep(t / 1000.0)
300301
result = fn(*args, **kwargs)
301-
if asyncio.iscoroutine(result):
302+
if inspect.isawaitable(result):
302303
await result
303304

304305
task = asyncio.create_task(delayed())
@@ -496,16 +497,17 @@ def throttle(fn: Callable, t: float) -> Callable:
496497
def throttled(*args, **kwargs):
497498
nonlocal last_call
498499
now = time.time()
499-
500+
should_call = False
501+
500502
with lock:
501503
if now - last_call >= t / 1000.0:
502504
last_call = now
503-
# 注: fn自体が長時間ブロックする可能性がある場合は
504-
# 別スレッドで実行するか、lockのスコープを狭めるなどの工夫が必要
505-
fn(*args, **kwargs)
505+
should_call = True
506506

507-
return throttled
508-
```
507+
if should_call:
508+
fn(*args, **kwargs)
509+
510+
return throttled```
509511

510512
### Q6. LeetCodeで提出できる?
511513

public/Algorithm/Other/leetcode/83. Remove Duplicates from Sorted List/Claude 4.6 extended/README_React.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,12 @@ <h3 className="mt-0 mb-3 text-teal-800 text-base font-bold outfit">
997997
<button
998998
type="button"
999999
className="px-4 py-2 rounded-xl font-semibold text-white transition disabled:opacity-50 shadow hover:-translate-y-0.5 bg-[linear-gradient(135deg,#10b981,#059669)] text-sm"
1000-
onClick={() => setIsPlaying(true)}
1000+
onClick={() => {
1001+
if (activeStep === stepsData.length) {
1002+
setActiveStep(1);
1003+
}
1004+
setIsPlaying(true);
1005+
}}
10011006
disabled={isPlaying}
10021007
>
10031008
▶ Play

0 commit comments

Comments
 (0)