Repository: fyne-io/fyne
File: widget/entry.go (Go)

Code before:
func (r *entryRenderer) trailingInset() float32 {
	th := r.entry.Theme()
	xInset := float32(0)

	if r.entry.ActionItem != nil {
		xInset = r.entry.ActionItem.MinSize().Width
	}

	if r.entry.Validator != nil {
		iconSpace := th.Size(theme.SizeNameInlineIcon) + th.Size(theme.SizeNameLineSpacing)
		if r.entry.ActionItem == nil {
			xInset = iconSpace + th.Size(theme.SizeNameInnerPadding)
		} else {
			xInset += iconSpace
		}
	}

	return xInset
}

func (r *entryRenderer) leadingInset() float32 {
	th := r.entry.Theme()
	xInset := float32(0)

	if r.entry.Icon != nil {
		iconSpace := th.Size(theme.SizeNameInlineIcon) + th.Size(theme.SizeNameLineSpacing) + th.Size(theme.SizeNameInnerPadding)
		xInset = iconSpace
	}

	return xInset
}

func (r *entryRenderer) Layout(size fyne.Size) {
	th := r.entry.Theme()
	borderSize := th.Size(theme.SizeNameInputBorder)
	iconSize := th.Size(theme.SizeNameInlineIcon)
	innerPad := th.Size(theme.SizeNameInnerPadding)
	inputBorder := th.Size(theme.SizeNameInputBorder)

	// 0.5 is removed so on low DPI it rounds down on the trailing edge
	r.border.Resize(fyne.NewSize(size.Width-borderSize-.5, size.Height-borderSize-.5))
	r.border.StrokeWidth = borderSize
	r.border.Move(fyne.NewSquareOffsetPos(borderSize / 2))
	r.box.Resize(size.Subtract(fyne.NewSquareSize(borderSize * 2)))
	r.box.Move(fyne.NewSquareOffsetPos(borderSize))

	pad := theme.InputBorderSize()
	actionIconSize := fyne.NewSize(0, size.Height-pad*2)
	if r.entry.ActionItem != nil {
		actionIconSize.Width = r.entry.ActionItem.MinSize().Width
		r.entry.ActionItem.Resize(actionIconSize)

Review comment (suggestion):
Looking at how `trialingInset` is calculated I don't think the `Padding` item is needed here.
Plus probably no point in the new `iconSpace` variable.

Code after:
func (r *entryRenderer) trailingInset() float32 {
	th := r.entry.Theme()
	xInset := float32(0)

	if r.entry.ActionItem != nil {
		xInset = r.entry.ActionItem.MinSize().Width
	}

	if r.entry.Validator != nil {
		iconSpace := th.Size(theme.SizeNameInlineIcon) + th.Size(theme.SizeNameLineSpacing)
		if r.entry.ActionItem == nil {
			xInset = iconSpace + th.Size(theme.SizeNameInnerPadding)
		} else {
			xInset += iconSpace
		}
	}

	return xInset
}

func (r *entryRenderer) leadingInset() float32 {
	th := r.entry.Theme()
	xInset := float32(0)

	if r.entry.Icon != nil {
		xInset = th.Size(theme.SizeNameInlineIcon) + th.Size(theme.SizeNameLineSpacing)
	}

	return xInset
}

func (r *entryRenderer) Layout(size fyne.Size) {
	th := r.entry.Theme()
	borderSize := th.Size(theme.SizeNameInputBorder)
	iconSize := th.Size(theme.SizeNameInlineIcon)
	innerPad := th.Size(theme.SizeNameInnerPadding)
	inputBorder := th.Size(theme.SizeNameInputBorder)

	// 0.5 is removed so on low DPI it rounds down on the trailing edge
	r.border.Resize(fyne.NewSize(size.Width-borderSize-.5, size.Height-borderSize-.5))
	r.border.StrokeWidth = borderSize
	r.border.Move(fyne.NewSquareOffsetPos(borderSize / 2))
	r.box.Resize(size.Subtract(fyne.NewSquareSize(borderSize * 2)))
	r.box.Move(fyne.NewSquareOffsetPos(borderSize))

	pad := theme.InputBorderSize()
	actionIconSize := fyne.NewSize(0, size.Height-pad*2)
	if r.entry.ActionItem != nil {
		actionIconSize.Width = r.entry.ActionItem.MinSize().Width
		r.entry.ActionItem.Resize(actionIconSize)
		r.entry.ActionItem.Move(fyne.NewPos(size.Width-actionIconSize.Width-pad, pad))