• R/O
  • SSH
  • HTTPS

yash: 提交


Commit MetaInfo

修訂4079 (tree)
時間2020-09-20 22:08:59
作者magicant

Log Message

Less memory allocation

Change Summary

差異

--- yash/trunk/path.c (revision 4078)
+++ yash/trunk/path.c (revision 4079)
@@ -1609,31 +1609,30 @@
16091609
16101610 bool print_umask_symbolic(mode_t mode)
16111611 {
1612- xstrbuf_T outputtext;
1612+ char outputtext[19];
1613+ char *c = outputtext;
16131614
1614- sb_initwithmax(&outputtext, 18);
1615- sb_ccat(&outputtext, 'u');
1616- sb_ccat(&outputtext, '=');
1617- if (!(mode & S_IRUSR)) sb_ccat(&outputtext, 'r');
1618- if (!(mode & S_IWUSR)) sb_ccat(&outputtext, 'w');
1619- if (!(mode & S_IXUSR)) sb_ccat(&outputtext, 'x');
1620- sb_ccat(&outputtext, ',');
1621- sb_ccat(&outputtext, 'g');
1622- sb_ccat(&outputtext, '=');
1623- if (!(mode & S_IRGRP)) sb_ccat(&outputtext, 'r');
1624- if (!(mode & S_IWGRP)) sb_ccat(&outputtext, 'w');
1625- if (!(mode & S_IXGRP)) sb_ccat(&outputtext, 'x');
1626- sb_ccat(&outputtext, ',');
1627- sb_ccat(&outputtext, 'o');
1628- sb_ccat(&outputtext, '=');
1629- if (!(mode & S_IROTH)) sb_ccat(&outputtext, 'r');
1630- if (!(mode & S_IWOTH)) sb_ccat(&outputtext, 'w');
1631- if (!(mode & S_IXOTH)) sb_ccat(&outputtext, 'x');
1632- sb_ccat(&outputtext, '\n');
1615+ *c++ = 'u';
1616+ *c++ = '=';
1617+ if (!(mode & S_IRUSR)) *c++ = 'r';
1618+ if (!(mode & S_IWUSR)) *c++ = 'w';
1619+ if (!(mode & S_IXUSR)) *c++ = 'x';
1620+ *c++ = ',';
1621+ *c++ = 'g';
1622+ *c++ = '=';
1623+ if (!(mode & S_IRGRP)) *c++ = 'r';
1624+ if (!(mode & S_IWGRP)) *c++ = 'w';
1625+ if (!(mode & S_IXGRP)) *c++ = 'x';
1626+ *c++ = ',';
1627+ *c++ = 'o';
1628+ *c++ = '=';
1629+ if (!(mode & S_IROTH)) *c++ = 'r';
1630+ if (!(mode & S_IWOTH)) *c++ = 'w';
1631+ if (!(mode & S_IXOTH)) *c++ = 'x';
1632+ *c++ = '\n';
1633+ *c++ = '\0';
16331634
1634- bool result = xprintf("%s", outputtext.contents);
1635- sb_destroy(&outputtext);
1636- return result;
1635+ return xprintf("%s", outputtext);
16371636 }
16381637
16391638 int set_umask(const wchar_t *maskstr)
Show on old repository browser