Skip to content

Conversation

@arturmelanchyk
Copy link
Contributor

No description provided.

@RPRX
Copy link
Member

RPRX commented Feb 7, 2025

麻烦基于 07c35ed rebase 一下

Signed-off-by: Artur Melanchyk <arturmelanchyk@imail.name>
Signed-off-by: Artur Melanchyk <arturmelanchyk@imail.name>
@arturmelanchyk
Copy link
Contributor Author

Hi @RPRX
the branch has been rebased

@RPRX
Copy link
Member

RPRX commented Feb 7, 2025

这是在解决什么问题?Golang 的新行为?

@RPRX
Copy link
Member

RPRX commented Feb 7, 2025

虽然 struct{} 在 Golang 中地位确实特殊

有相关解释发来看一下吗

@RPRX
Copy link
Member

RPRX commented Feb 7, 2025

你的意思是反正存储 true 或 false 都用不到,不如用空值 struct{}

@arturmelanchyk
Copy link
Contributor Author

@RPRX
in this specific case map[string]bool is used as a Set, to keep unique values as keys of the map. The bool is redundant and not needed. By having struct{} instead of irrelevant bool values we avoid unneeded memory allocation as well as we avoid confusion for developers

@RPRX
Copy link
Member

RPRX commented Feb 7, 2025

这下真把 map 用成集合了

@RPRX RPRX changed the title fix: make portsInUse map a set Chore: Make some Maps into Sets Feb 7, 2025
@RPRX RPRX changed the title Chore: Make some Maps into Sets Chore: Make some Maps into real Sets Feb 7, 2025
@RPRX RPRX merged commit ae327eb into XTLS:main Feb 7, 2025
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.

2 participants